I have a GWTP Presenter in which I want to add an undetermined number of instances of GWTP PresenterWidget. To each of that instances I need to pass an argument (a different argument to each instance) that the parent Presenterowns.
There are two things that I need to accomplish here:
1. Instantiate an undetermined number of PresenterWidget
- Reading here, it looks like I just need a Provider.
2. Transfer to each of those PresenterWidget the argument I want.
- ProxyEvent does not seem an option since the PresenterWidget has no proxy
- I need to pass the argument before revealing the PresenterWidget
- Is it possible or is it a good practice to just declare a public method on the PresenterWidget and access it from the parent presenter?
For example:
public class MyWidgetPresenter extends PresenterWidget<MyWidgetPresenter.MyView> {
...
private MyArgument argument;
public void setArgument(MyArgument argument){
this.argument=argument;
}
And then the Parent presenter could:
@Inject Provider<MyWidgetPresenter> myWidgetPresenterProvider;
...
[this could be part of a loop]
MyWidgetPresenter myWidgetPresenter = myWidgetPresenterProvider.get();
myWidgetPresenter.setArgument(argument);
getView().addToSlot(SLOT_MyWidgetPresenters, myWidgetPresenter);
[loop end]
Is this a valid solution at all? I have implemented it and everything works except that my PresenterWidget never calls onReveal or onReset which prevents to show the content. Any ideas why?