PDA

View Full Version : What if on Mail example the bean MailItem won't extend BaseModel



Pietro Marrone
12 Sep 2009, 1:31 PM
In the Mail example on MailController class in the method onViewMailItems we get the List<MailItem>
from the service and then pass them to the View using the created AppEvent, as reported:


private void onViewMailItems(final AppEvent event) {
final Folder folder = event.getData();
if (folder != null) {
service.getMailItems(folder, new AsyncCallback<List<MailItem>>() {
public void onSuccess(List<MailItem> result) {
AppEvent ae = new AppEvent(event.getType(), result);
ae.setData("folder", folder);
forwardToView(mailView, ae);
}

public void onFailure(Throwable caught) {
Dispatcher.forwardEvent(AppEvents.Error, caught);
}
});
}
}
till now all is ok, but what shuold we pass if our beans are not extending BaseModel, but using @BEAN annotation and BeanModelMarker, and to get and convert beans we need to use the RpcProxy, BeanModelReader and the ListLoader in similar form:



RpcProxy proxy = new RpcProxy() {
@Override
public void load(Object loadConfig, AsyncCallback callback) {
myService.getArchive(callback);
}
};

BeanModelReader reader = new BeanModelReader();
ListLoader loader = new BaseListLoader(proxy, reader);
So, my question is from architectural prospective how to break code from the controller, view and the panel/widget.

Regards