flyer
10 Mar 2009, 7:12 AM
GXT comes with a nice Mail App sample. It shows basic example of a GXT MVC framework. But I have nor found any others samples or documentation except javadoc.
In the Mail App MailController handles the ViewMailItems event, loads the data using service, creates new event with the retreived data, sends it to a MailView. MailView sets the data on a MailListPanel and shows it. Seems very easy and clean.
In a real application I want to use a pagination. Short code
RpcProxy<PagingLoadConfig, PagingLoadResult<UserDTO>> proxy =
new RpcProxy<PagingLoadConfig, PagingLoadResult<UserDTO>>() {
@Override
protected void load(PagingLoadConfig loadConfig,
AsyncCallback<PagingLoadResult<UserDTO>> callback) {
administrationService.getUsers(loadConfig, callback);
}
};
BasePagingLoader<PagingLoadConfig, PagingLoadResult<UserDTO>> loader =
new BasePagingLoader<PagingLoadConfig, PagingLoadResult<UserDTO>>(
proxy, new BeanModelReader<UserDTO>());
loader.load(0, 50);
store = new ListStore<BeanModel>(loader);
final PagingToolBar toolBar = new PagingToolBar(2);
toolBar.bind(loader);
grid = new Grid<BeanModel>(store, columnModel);
The constructor of the loader requires the proxy. Loader must passed to the store, store to the grid. So I can't just create a public getter for the store and fill it with data from the View.
What is the best way to organise code like this? I don't want to send a ref to the AdministrationService to the widget (UserListPanel). As far as I understand it's not a best way. Probably the more correct way is to create proxy in the Controller, pass to the View, in the view create loader, store and grid on the widget. But it's not so clean and easy as an example. I need a lot of code (which should be in the UserListPanel) in my UsersView and I need to recreate many objects (in the Mail sample MailView just sets the data mailListPanel.getStore().add((List) event.data)).
What do you think about it? And is there any documentation or samples for the GXT MVC?
Regards,
Alexey.
In the Mail App MailController handles the ViewMailItems event, loads the data using service, creates new event with the retreived data, sends it to a MailView. MailView sets the data on a MailListPanel and shows it. Seems very easy and clean.
In a real application I want to use a pagination. Short code
RpcProxy<PagingLoadConfig, PagingLoadResult<UserDTO>> proxy =
new RpcProxy<PagingLoadConfig, PagingLoadResult<UserDTO>>() {
@Override
protected void load(PagingLoadConfig loadConfig,
AsyncCallback<PagingLoadResult<UserDTO>> callback) {
administrationService.getUsers(loadConfig, callback);
}
};
BasePagingLoader<PagingLoadConfig, PagingLoadResult<UserDTO>> loader =
new BasePagingLoader<PagingLoadConfig, PagingLoadResult<UserDTO>>(
proxy, new BeanModelReader<UserDTO>());
loader.load(0, 50);
store = new ListStore<BeanModel>(loader);
final PagingToolBar toolBar = new PagingToolBar(2);
toolBar.bind(loader);
grid = new Grid<BeanModel>(store, columnModel);
The constructor of the loader requires the proxy. Loader must passed to the store, store to the grid. So I can't just create a public getter for the store and fill it with data from the View.
What is the best way to organise code like this? I don't want to send a ref to the AdministrationService to the widget (UserListPanel). As far as I understand it's not a best way. Probably the more correct way is to create proxy in the Controller, pass to the View, in the view create loader, store and grid on the widget. But it's not so clean and easy as an example. I need a lot of code (which should be in the UserListPanel) in my UsersView and I need to recreate many objects (in the Mail sample MailView just sets the data mailListPanel.getStore().add((List) event.data)).
What do you think about it? And is there any documentation or samples for the GXT MVC?
Regards,
Alexey.