PDA

View Full Version : reload a single object!



DaRkViDe
7 Dec 2010, 4:05 AM
This question can appear very stupid...
I need to load a single object (Bean) from server side without go through the controller and view but directly on the panel that displays the object!
I loaded a lot of list of objects with rpc proxy, reader and loader and all works fine
I need to load this object synchronously, is it possible?

This example can be totally wrong...it was just to get an idea of what i need to do...
If i use an rpc proxy like the following metod:


public MyModel reloadMyModel() {

final MyModelServiceAsync MyModeloService = Registry
.get(Abi.MyModel_SERVICE);

RpcProxy<MyModel> MyModelProxy = new RpcProxy<MyModel>() {

@Override
protected void load(Object loadConfig,
AsyncCallback<MyModel> callback) {

//this method return a single object
//it works fine via cotroller and view
MyModelService.getMyModel(param, callback);

}
};

BaseLoader<MyModel> l = new BaseLoader<MyModel>(MyModelProxy);
l.load();


//PROBLEM: how to set the result of the loader on the object?
MyModel m = ??????

//return the object updated
return m;


}



Anywone helps???

sven
7 Dec 2010, 4:08 AM
I need to load this object synchronously, is it possible?

GWT does not supprot sync calls directly and in 99,9999% cases sync calls are unneeded.

You will need to change your logic to be callback based instead of using a return statement.

DaRkViDe
7 Dec 2010, 4:20 AM
is there some post about this? any example? Tnx

sven
7 Dec 2010, 4:26 AM
There is much sample code out there that show you how to use callbacks. I dont have any sample code for your direct need.