I have:
- Simple Nested presenter (ChannelPresenter) which has table(grid) with records in it. I need to create new ChannelEditorPresenter instance in each ChannelPresenter.displayEditor() call.
- Popup Presenter Widget (ChannelEditorPresenter) which should display popup in each ChannelEditorPresenter.edit() call
Currently I'm injecting ChannelEditorPresenter to ChannelPresenter constructor, but in this case I have only one instance of the ChannelEditorPresenter. Actually I need separate Popup presenter for each call. (A lot of separated windows, each has own data).
ChannelPresenter.java:
public class ChannelPresenter extends Presenter<ChannelPresenter.MyView, ChannelPresenter.MyProxy> implements ChannelUiHandlers {
public interface MyView extends View, HasUiHandlers<ChannelUiHandlers> {
void load();
}
@ProxyStandard
@NameToken(NameTokens.CHANNELS)
interface MyProxy extends ProxyPlace<ChannelPresenter> {
}
ChannelEditorPresenter channelEditorPresenter;
@Inject
ChannelPresenter(EventBus eventBus, MyView view, MyProxy proxy,
ChannelEditorPresenter channelEditorPresenter
) {
super(eventBus, view, proxy, ApplicationPresenter.SLOT_MAIN);
getView().setUiHandlers(this);
this.channelEditorPresenter = channelEditorPresenter;
}
@Override
protected void onBind() {
super.onBind();
getView().load();
}
@Override
public void displayEditor(Channel channel) {
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Here I need to create new instance for each call
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
addToPopupSlot(channelEditorPresenter);
channelEditorPresenter.edit(channel);
}
}
I found solution here: Instantiate a PresenterWidget (GWTP) manually
I need to Inject com.google.inject.Provider<ChannelEditorPresenter> instead of plain ChannelEditorPresenter.
ChannelPresenter.java: