Share user input data within MVP + Lady_Gaga

7 views
Skip to first unread message

mk

unread,
Jul 19, 2010, 5:54:02 PM7/19/10
to Google Web Toolkit
How to share user input data within MVP.

Following is one of MVP sequence for TWO widgets

1) 1st VIEW has a simple textbox and submit button, wherein use
enters
her name "Lady_Gaga" and click submit.
2) 1st PRESENTER fires an event ( cuz of button click).
3) 2nd PRESENTER catches that event and displays 2nd VIEW as dialog
box with user entered name "Lady_Gaga"

Question) How user entered name "Lady_Gaga" be passed from 1st VIEW
to
2nd VIEW ?

Arthur Kalmenson

unread,
Jul 19, 2010, 5:59:27 PM7/19/10
to google-we...@googlegroups.com
Isn't the second presenter setting the value in the second view based
on the event it just caught? You're describing the interaction right
there.

--
Arthur Kalmenson

> --
> You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

mk

unread,
Jul 19, 2010, 9:04:47 PM7/19/10
to Google Web Toolkit
Thanks a lot.

Now if there are three DIFFERENT presenters (say 2a,2b,2c) listening
event from 1st presenter.
Than do 1st presenter has to create event with all the appro. values
required by 2a,2b,2c presenters?

Plz respond.
> > For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en.- Hide quoted text -
>
> - Show quoted text -

Arthur Kalmenson

unread,
Jul 20, 2010, 8:53:03 AM7/20/10
to google-we...@googlegroups.com
No, they should all use the same single event.

--
Arthur Kalmenson

Eric

unread,
Jul 20, 2010, 10:21:17 AM7/20/10
to Google Web Toolkit


On Jul 19, 9:04 pm, mk <munna.kaka.ch...@gmail.com> wrote:
> Thanks a lot.
>
> Now if there are three DIFFERENT presenters (say 2a,2b,2c) listening
> event from 1st presenter.
> Than do 1st presenter has to create event with all the appro. values
> required by 2a,2b,2c presenters?

In fact, you shouldn't be thinking about presenters 2a, 2b, or 2c
when writing presenter 1. Presenter 1 should just fire change
events when its data changes. Presenters 2a, 2b, 2c, and future
presenters 3q and 7f should simply add event handlers to
presenter 1 and pick out the information they need.

Eric

mk

unread,
Jul 20, 2010, 12:07:04 PM7/20/10
to Google Web Toolkit
In case future presenter 3q requires a specific information which is
not sent in the old event thrown by presenter 1.
Than in future, we have to add that specific information in the event
thrown by presenter 1 .. right ?

I mean information passed in the event is limited by what is required
by listening presenters?.

For eg a registration view may have different textboxes for first
name, address etc and the intial event may only be thrown with the
information that "submit button is clicked". And later on for future
presenter 3q we may have to add first name in the event thrown by
presenter 1.

Do you create event in the first place with all the information
available to accomodate all future presenters?
Do you create a "Value object" to pass this heavy weight information
from one presenter to another?


Thanks in adv....Plz respond....

Mikael Couzic

unread,
Jul 20, 2010, 2:34:37 PM7/20/10
to Google Web Toolkit
Well, I pretty much agree with Eric. I believe the event should'nt
depend on the listeners, rather it should be defined in consideration
of the presenter that fires it. The attributes stored in the event are
the ones that make sense in its own context (that helps a lot I know
^^).
In your registration example, I'd fire a RegistrationSubmittedEvent
that holds all the details of the registration. No need to create a
data object, your event is your data object. However, you can
instantiate model objects in the presenter and hold these objects in
the event instead of duplicating instantiation code all over the
listeners. But in that case, be careful, your model objects are shared
and shouldn't be edited (consider making them immutable).

I hope that helps !

PhilBeaudoin

unread,
Jul 20, 2010, 7:54:49 PM7/20/10
to Google Web Toolkit
Another approach that wasn't mentioned but that I use quite frequently
is to use the history and pass the information as parameters in the
history token. This is made really easy in frameworks like gwt-
presenter and gwt-platform and has a number of advantages provided the
parameter is serializable (and small enough). For example, it could
let the user bookmark the detail page of "Lady_Gaga". A bit trickier
when the presenter is a dialog box, but totally doable.

Thomas Broyer

unread,
Jul 21, 2010, 10:17:51 AM7/21/10
to Google Web Toolkit


On 21 juil, 01:54, PhilBeaudoin <philippe.beaud...@gmail.com> wrote:
> Another approach that wasn't mentioned but that I use quite frequently
> is to use the history and pass the information as parameters in the
> history token. This is made really easy in frameworks like gwt-
> presenter and gwt-platform and has a number of advantages provided the
> parameter is serializable (and small enough). For example, it could
> let the user bookmark the detail page of "Lady_Gaga". A bit trickier
> when the presenter is a dialog box, but totally doable.

This has the drawback that you cannot "cancel navigation" (because in
this case it's about navigation, not "any custom event"), e.g. for
cases where you changed some values in a form but didn't save them.
But this is easily solved by frameworks with the concept of "places",
that generally have 2 events: place change requested (cancellable) and
place change (in case the first wasn't cancelled).
It just moves the problem though, it doesn't really solve it (what if
you didn't "serialize" 'enough' information into the "place"?)
Reply all
Reply to author
Forward
0 new messages