zaccret
05-21-2008, 10: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.
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.