View Full Version : GXT MVC design model best practice

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>>() {
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);

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?


10 Mar 2009, 10:05 AM
I have had the same questions. The following post has the best response, I have seen, so far is:

I think GXT might want to include a PagedResponseAsyncCallback class to make it clearer, what the "right thing" is to do.

10 Mar 2009, 10:12 PM
speajus thanks for the link! Very useful post.

11 Mar 2009, 1:25 AM
Hello everbody,

I would like to know if the built in MVC approach will still be a best practice or to be extended in the future of GXT? I want to develop a medium sized application and don't know if I should use the mvc package provided by GXT. I know that this question is not exactly relating to the topic, but I did not want to open a new thread for this. Nevertheless it would be great if someone could help me with that decision.

18 Mar 2009, 12:32 PM
Hi JensHeyer,

[...] I want to develop a medium sized application and don't know if I should use the mvc package provided by GXT. [...]

From http://extjs.com/forum/showthread.php?t=34860 (http://extjs.com/forum/showthread.php?t=34860:):

When you have experience with UI development [...] you will realize that every non trivial application has to be separated carefully.

From my point of view it is necessary to base on a powerfull [sic] well thought framework and to establish rools [sic] [for] how the different parts of your app communicate with each other in a well defined way. When you do the development with the "one-shot Composite widgets" approach you will end up in a maintenance nightmare rather soon.