1

I've searched as much as I could but did not find any answers/examples for my question.

I'm completely new to Web UI development but have a decade and a half of experience in Java and other languages. I seem to be completely lost in the sea of available options for the client side, but for the server side I have a Rest server (Play) running already. I can't and don't want to use a complete package for both client and server b/c I want to pass JSON back and forth between the server and the client. This way I can use multiple different clients: web, Excel, Swing, etc. I want to keep it flexible like this.

So far I pretty much decided to use GXT for the client side, and found RestyGWT to be sitting in the middle. This is what causes my problems. So far, I have not been able to find a single example of a GXT + RestyGWT combination. Just a single example (a Grid for example) would be extremely helpful, since I have no experience with J2EE, beans, or any of that.

Any help or examples with GXT + RestyGWT would be greatly appreciated!

siki
  • 9,077
  • 3
  • 27
  • 36
  • I've done a decent amount of work with GXT/RestyGWT recently but am not sure how far you have gone with this since the last post. If you need more help, I can provide more detailed examples from my working code. – Joel Nov 16 '14 at 22:55

2 Answers2

1

What have you tried? RestyGWT is serialization and transport, so ideally you set up a loader that describes what you need based on your widgets (grid? paging toolbar? filters?), and then pass it a DataProxy implementation that knows how to take config objects, and asynchronously send back loaded data objects. Each grid example that loads from the server uses a loader, but a different proxy (and optionally reader) based on whether it us using RPC, RequestFactory or XML/JSON over HTTP. There is also a JSONP example, and while it isn't using the Grid, it is still loading items to a ListStore, so could easily be attached to a grid.

DataProxy is a simple interface - it is given a config object and a callback to invoke when the load is finished or to notify if an error occurred. In your implementation of this interface, call your service with the necessary details of the config, and then invoke the callback when results are ready.

Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
  • I've made a little bit of progress since my OP but I'm still far, I think. If I understand it correctly, RestyGWT will deserialize the JSON response (for example) into Java objects or Beans. I think I can do that now, but it seems to me that these are just plain old Java objects. Do I then need to turn these objects into something else to be able to add them to a ListStore, for example? If yes, how? – siki Dec 10 '13 at 20:37
  • 1
    Nope, that's it! ListStore can handle anything (even primitives, as long as you can define a ModelKeyProvider for it). The PropertyAccess stuff looks for getters and setters to generate ways to read and write values without reflection, otherwise you can always write your own implementation of ValueProvider, etc. – Colin Alworth Dec 10 '13 at 21:08
  • Note that GXT 2 was not so flexible, it required you to implement or extend something, but in GXT 3 you can make a `Grid` or a `Tree` if you really wanted to. PropertyAccess doesn't play nice with java.lang right now, but you can still manually create ValueProviders, etc. – Colin Alworth Dec 10 '13 at 21:11
  • Awesome! Thanks for taking the time to reply. – siki Dec 10 '13 at 21:35
0

If you want an example of how RestyGWT works you can have a look to
one of my blog article. It is a pure GWT example but should work with GXT as well. GXT is mostly about graphical components for GWT.

In 2 words you need to

1) Define your restServices interfaces

public interface HelloClient extends RestService {    
  @GET
  public void getHellos( MethodCallback<List<Hello>> callback);
}

2) Create your client

HelloClient client = GWT.create(HelloClient.class);

3) Use it

client.getHellos(new MethodCallback<List<Hello>>() {

    public void onSuccess(Method method, List<Hello> response) {
    //...
    }

    public void onFailure(Method method, Throwable exception) {
     //...
    }
  });
Ronan Quillevere
  • 3,699
  • 1
  • 29
  • 44