I am using GWTP for an application. In this app, I often need to do a PresenterWidget
which contains tabs with a PresenterWidget
in each tab.
As the container is a PresenterWidget
, I cannot use class TabContainerPresenter
so I am doing my own implementation.
I encounter some problems while trying to manage the lifecycle of PresenterWidget
contained in the tabs (onReveal()
, onHide()
etc).
First question : In this particular case, is it recommended to manually call onReveal()
, onHide()
etc?
2nd question : I tried to manage lifecycle without calling those methods.
This is what I do : When user clicks on a tab, the main presenter calls setInSlot(index,presenterWidget)
to put the corresponding PresenterWidget
in the right tab.
But : When I click on a tab, onReveal()
is called on the corresponding PresenterWidget
(good!) then onReset()
is called on all PresenterWidget
: why all? I would expect that onReset()
is called only on the PresenterWidget
corresponding to the active tab.
=> Is setInSlot()
the right method to call in this case?
Maybe this might be of help: https://github.com/ArcBees/GWTP/wiki/Presenter-%22Slots%22
setInSlot()
method because at any point only one PresenterWidget
is active. However you are using different SLOTS for each PresenterWidget
. The way setInSlot()
works is that it replaces whatever PresenterWidget
that was assigned to that slot. Because you use different slots for each tab, it won't remove the other PresenterWidgets
. The other PresenterWidget
s stay in their slots and probably that's the reason why onReset()
is called on them.
You have 2 choices:
removeFromSlot
on all non-visible PresenterWidgets
.setInSlot()