开发者

Revealing nester presenter in GWTP on first page access

开发者 https://www.devze.com 2023-03-27 09:35 出处:网络
I\'m developing small 开发者_StackOverflow社区application using GWT and GWTP, but I\'m completely new to these technologies and need a little help here.

I'm developing small 开发者_StackOverflow社区application using GWT and GWTP, but I'm completely new to these technologies and need a little help here.

I try to use nested presenter feature. But I have doubts, if I understand its intention correctly...

So, my application is supposed to have several lists of items in 2 kind of frames. Consider them as folders and files.

I've developed MainPage view and presenter, it has only several layout panels. I'd like to implement my lists of items (represented as custom widgets) as separate presenters. For example one if them is called ItemsListPresenter.

I created slot in MainPagePresenter, implemented ItemsListPresenter.revealInParent() method to insert presenter in that slot.

But how should I reveal ItemsListPresenter? It's onBind() even not called.

I know, that I have to call method of PlaceManager for this. My question is, how this call should be actually performed to conform best practices?

Would it be ok, to inject PlaceManager into my MainPagePresenter, and call it's method directly in onBind() method?

Thanks in advance.


You also have to implement the setInSlot() method of your MainPageView, like this:

@Override
public void setInSlot(Object slot, Widget content) {
    if (slot == MainPagePresenter.TYPE_SetMainContent) {
       mainContentPanel.clear();
       if (content != null) {
          mainContentPanel.add(content);
       }

    } else {
      super.setInSlot(slot, content);
    }
}

where MainPagePresenter.TYPE_SetMainContent is your content slot, and mainContentPanel is the MainView panel in which you want to reveal the nested presenter. Also your main presenter should not be a place, only your nested presenters are places.

You can use the methods in PlaceManager to programmatically switch the currently displayed nested presenter (you can only display one at a time). You can use gin to inject the PlaceManager where you need it. Or you can switch using hyperlinks in a menu like this:

<g:InlineHyperlink targetHistoryToken="{nameTokens.getFistItemsListPage}">
     First items list
</g:InlineHyperlink>
<g:InlineHyperlink targetHistoryToken="{nameTokens.getSecondItemsListPage}">
     Second items list
</g:InlineHyperlink>

If you want to display several sub presenters at once, you have to use presenter widgets instead of nested presenters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号