Communicate date from Parent to Child Presenter

30 views
Skip to first unread message

Harsh Yadav

unread,
Aug 26, 2016, 11:15:28 AM8/26/16
to GWTP
I have a Presenter (with Proxy), and I display multiple child presenters (with ProxyPlace) inside the parent presenter.

Parent Presenter:

@ProxyStandard
@NoGatekeeper
public interface MyProxy
extends Proxy<ParentPresenter> {
}


Child Presenters:

@NameToken (NameTokens.CHILD)
@ProxyCodeSplit
public interface MyProxy
extends ProxyPlace<ChildPresenter> {
}


The parent presenter gets the common data and display it in the top main menu. So far so good.
When the parent presenter gets the data, it uses the event bus to generate an event. The child presenters implements the handler to listen to the event.

The issue is that I want the parent presenter to load the new common data, only on the place change i.e. when the URL parameter changes.
Since the Proxy presenters don't implement prepareFromRequest, I cant do that in Parent Presenter.

I can work around with that, by loading common data in either onReset() or by implementing a NavigationEvent in the parent presenter.
However in that case, the data would be loaded unnecessarily, even when not needed.

For e.g.
if the URL parameter is product=1, the child presenters look like:
#child1;product=1
#child2;product=1

I want the Parent Presenter to only request the new data, if the actual URL parameter changes.
That is:
Load new data if URL changes from:
#child1;product=1 TO #child1;product=2

OR

#child1;product=1 TO #child2;product=2


NOT when it changes from:
#child1;product=1 TO #child2;product=1


What I can do is check in the Parent Presenter, if the current history parameter is same or different than the previous one, and then load new data.
But is there a better way to do this. I want to call my data service only when needed.


Thanks,
Harsh
Reply all
Reply to author
Forward
0 new messages