tags:

views:

259

answers:

1

Hello there,

I am trying to develop a GWT app with the MVP pattern. So far so good except for one specific case of actions: actions that do not change the url (no browser history change).

In the GWT MVP pattern, events are sent from presenters, the an app controller catches them and update the browser history. If the history has changed then the view updates.

** MVP with history change (Works well)**

Current URL is /list
User clicks on contactdelete button.
Fire DeleteContactAction event.
App controller catches, change history to 'delete'
onValueChange is called
if (token.equals("delete")) 
delete contact screen, then delete contact
Fire ContactDeletedEvent 
app controller catches and change the history to list 
onValueChange is called: contact list refreshes

GWT MVP pattern for dialog box w/o history changes

** Issue ** - I use a dialog box and I don't want to change the browser history, so here is the problem:

  Current URL is /list
  User clicks on contactdelete button.
  Contact is deleted
  Fire ContactDeletedEvent.
  App controller catches, change history to 'list'
  **onValueChange is NOT called** because url is already /list and there is no change
  # problem: contact list does not refresh

Question: does anyone know a pattern to implement this in the context of MVP?

Any help / idea appreciated.

A: 

Are you using some framework (aside from GWT) that automatically does history changes?

Regular GWT/MVP doesn't require a history change to be made, and in fact usually it's up to the app to update the history itself.

If you want to update the app's state without a history change, you can use an EventBus to publish events that other elements of the app can subscribe to, to update the app's state without a history change.

Jason Hall
I am using the example from the tutorial here: http://code.google.com/webtoolkit/doc/latest/tutorial/mvp-architecture.htmlIn this example, events are collected by the appcontroller which changes the browser history to trigger processing. I am trying to keep the centralization of events in the appcontroller but trying to avoid * this event is treated like this: with history change * this one like that: w/o history change.See what I mean?
Okay, so instead of having AppController collect events and trigger history changes, which other parts of the app listen for, just have other parts of the app listen for the relevant events themselves. Another good framework for GWT MVP development is gwt-presenter, which is actively developed, unlike this example framework. http://code.google.com/p/gwt-presenter/
Jason Hall