TurboManage

David Chandler's Journal of Java Web and Mobile Development

  • David M. Chandler


    Web app developer since 1994 and former Developer Advocate with Google now residing in Colorado. Besides tech, I enjoy landscape photography and share my work at ColoradoPhoto.gallery.

  • Subscribe

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 241 other followers

  • Sleepless Nights…

    October 2009
    S M T W T F S
    « Sep   Nov »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • Blog Stats

    • 857,849 hits

GWT PropertyChangeListeners come full circle with MVP

Posted by David Chandler on October 6, 2009

I initially stumbled on the excellent Model-View-Presenter pattern for GWT while wading through discussion threads on the various library options for PropertyChangeSupport (since GWT does not offer it natively). In the process, I’ve found that I’m unable to completely avoid the need to store a few things in a client-side model, and the model turns out to be the most convenient place to fire an event indicating that the model has been updated, which looks an awful lot like…a PropertyChangeEvent/Listener.

	void setPrayerLists(List<PrayerList> prayerLists)
	{
		this.prayerLists = prayerLists;
		// Hah, we're back to PropertyChangeListeners, after all
		eventBus.fireEvent(new PrayerListsModifiedEvent(prayerLists));
	}

Of course, the event now being fired is now my own, not a PropertyChangeEvent, so I no longer need a PropertyChangeSupport emulation library and no longer have to worry about the accompanying idiosyncracies involving collections, etc. And thanks to GWT’s HandlerManager and related classes, I can fire events for any purpose, not just PropertyChangeEvents, and the event can carry a payload such as accompanying data in its constructor. I just mean to say that firing events off model changes still turns out to be useful in some cases. And I somehow find that humorous.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: