When to use a PresenterWidget vs a regular GWT widget.

644 views
Skip to first unread message

Casey Jordan

unread,
Aug 14, 2012, 8:25:48 PM8/14/12
to gwt-pl...@googlegroups.com
I am fairly new to GWTP/GWT so forgive me if this is a "newbish" question. I am trying to understand if the MVP design pattern advises that all re-useable widget components be PresenterWidgets, or if using plain old GWT widgets is also recommended and if/when for each.

For instance, I have a presenter-view which contains a left side tree. This tree will need to load based on data from the server, and also update based on events. Should create a new implementation of a Tree as a presenter widget, or should encapsulate the tree in a presenter widget, and then let the presenter widget delegate actions to the tree based on the event's it recieves? Or some other option, like binding the tree to it's data model and let changes in the data model delegate events to the tree.

I think this pattern will come up a lot, so I am trying to better understand how to aproach it in GWTP.

Thanks,

Casey

Casey Jordan

unread,
Aug 15, 2012, 10:54:37 AM8/15/12
to gwt-pl...@googlegroups.com
Ah! Thank you for that link, I thought I read the documentation thoroughly but looks like I missed that page.

I have to admit when I read the FAQ it was a light bulb moment. WOW! Really amazing. I think the search results example illustrates it really well.

We have an event bus in our javascript system which works very similarly to the MVC way. However we don't have anything like PresenterWidgets, and now that I see how powerful they are I can really understand how decoupled you could make your UI's and how much logic you could eliminate due to this.

So then to pose another question/thought experiment:

 Let's say I have a presenter tree, which is presenting some XML structure in tree form. Let's also assume that there are 3 users "viewing" this tree in different browser windows (Collaboratively). Say user 1 drag-drop re-orders the tree. This, in itself does not cause the tree to save, but this state should be propagated to the other users applications.

What would be the best way to accomplish this?

On our current system we use web sockets and we hold an in memory version of the data (model) server side. When this version changes the server broadcasts events to all of the specific clients via the web sockets causing the views to update.

I see the potential for the same system to work in GWTP but it would be nice to understand better.

Thanks,

Casey

On Wed, Aug 15, 2012 at 9:34 AM, regnoult axel <regn...@gmail.com> wrote:
Hi Casey,

Personnally, I am also a kind of beginner, I can just give you some links that maybe will help you :

PW vs Widget : 

MVP (a complete example)

If I am not doing a mistake, I will answer :
 - If you need to code a complex widget (communicate with the database etc...) => use a presenter widget (you will have a better organisation of your code)
 - MVP is better way than MVC to architecturate you code (advocated by Google, cf you tube: "RAY RYAN in google IO 2009" )

Good luck,
++








--
--
Casey Jordan
easyDITA a product of Jorsek LLC
"CaseyDJordan" on LinkedIn, Twitter & Facebook
(585) 348 7399
easydita.com


This message is intended only for the use of the Addressee(s) and may
contain information that is privileged, confidential, and/or exempt from
disclosure under applicable law.  If you are not the intended recipient,
please be advised that any disclosure  copying, distribution, or use of
the information contained herein is prohibited.  If you have received
this communication in error, please destroy all copies of the message,
whether in electronic or hard copy format, as well as attachments, and
immediately contact the sender by replying to this e-mail or by phone.
Thank you.

Casey Jordan

unread,
Aug 15, 2012, 11:28:12 AM8/15/12
to gwt-pl...@googlegroups.com
I have watched the video before. I think the big question remaining for me is how to tie the server/client even more tightly together via push communication from the server. I think this has been something historically saught after, esp. with the use of comet and long polling mechanisms in the past.

Web sockets, while not supported in older browsers natively (can use flash) seem to be an ideal match up for hooking to GWTP events. Then, instead of throwing events after an action has completed, the server would push events to all relevant clients if the action was successfully executed.

Anyone have thoughts about this?

Thanks,

Casey



On Wed, Aug 15, 2012 at 11:14 AM, regnoult axel <regn...@gmail.com> wrote:
I can t help you a lot this time, but the system existing to manage events in an application is the EVENT BUS (gwt, RAY RYAN 2009, you should look the video)...

With the GWTP eclipse plugin, you can create events very quickly......

Christian Goudreau

unread,
Aug 21, 2012, 11:00:45 AM8/21/12
to gwt-pl...@googlegroups.com
There's a lot of way to do this, and web sockets is one of them.

What could be done on the client side to propagate the event to interested presenters is to bind an EagerSingleton that listen to server events when the app starts using WebSockets. Then when it receive something, it use the eventbus to tell everything else that is interested what is going on.

WebSockets can be easily used with JSNI or the new Elements api from GWT 2.5 or by using a third party library.
--
Christian Goudreau
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages