PDA

View Full Version : Pure GWT RPC VS Data Loading API



zaccret
21 May 2008, 6:58 AM
Hi,

I would like to understand better the data loading API. In the case of a combo box, I can build myself the store with a pure GWT RPC, like that :

public void onModuleLoad() {
Viewport viewport = new Viewport();

final FormPanel panel = new FormPanel();
panel.setHeading("My panel");
panel.setWidth(400);

final ComboBox combo = new ComboBox();
combo.setFieldLabel("File");

final ListStore store = new ListStore();
final SimentServerServiceAsync serviceExercises = RPCServiceLocator.getExercisesService();
serviceExercises.getExerciceNames(new AsyncCallback<List<String>>() {
public void onFailure(Throwable caught) {}
public void onSuccess(List<String> result) {
for (String text : result) {
BaseModel model = new BaseModel();
model.set(combo.getDisplayField(), text);
store.add(model);
}
}
});
combo.setStore(store);
panel.add(combo);

viewport.add(panel);

RootPanel.get().add(viewport);
}
If I want to use the Data Loading API (ListStore + RpcProxy + BaseListLoader), then my service has to return a List (or ListLoadResult) of ModelData instead of List<String>.
The changes :
- the instantation/setup of the model will be made on the server side instead of client side
- the code seems to be a little more complex

In that case, I don't see the benefits of the Data Loading API. Can someone tell me if I'm wrong and in which cases we get the benefits of the API ? Thanks.

gslender
21 May 2008, 12:46 PM
Would it depend on your problem?

Info about data loading here http://extjs.com/learn/Documentation:Data_Loading kinda suggests that the problem being solved is broad (meaning perhaps size and paging) are the kind of problems solved that raw RPC would not be so easy.

If you only need simple loading, then yes, I'd guess plain GWT RPC might be more straight forward.

Its kinda like the argument for OO vs procedural coding - there is no doubt OO requires more keystrokes, but the longer term benefit when code size gets big is often where the value is.

Perhaps Darrell might have some further insight?