Frage

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?

War es hilfreich?

Lösung

Maybe this might be of help: https://github.com/ArcBees/GWTP/wiki/Presenter-%22Slots%22

  1. I wouldn't recommend to call the lifecycle method manually. It should work just fine without them.
  2. You want to use the 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 PresenterWidgets stay in their slots and probably that's the reason why onReset() is called on them.
You have 2 choices:

  • If you want to keep the different slots you should call removeFromSlot on all non-visible PresenterWidgets.
  • Specify just one slot (TAB_CONTENT) and simply use setInSlot()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top