简体   繁体   中英

History mangement in multi-level view in gwt using mvp

I have to create multi-level views for eg. TopLevelView contains a series of button horizontally place (works as menu).On clicking on buttonX-TopLevelView,It creates anotherView call MiddleView that gets appended in the container of TopView. Similary MiddleView has same structure as TopView. When we click on a buttonY-MiddleView which opens InnerLevel-View.

Now suppose we call URL : 127.0.0.1:7777/demoapp#innerLevel

I thought the flow as following

Pseudo Code :

First check for string innerLevel in appController history Tokenizer.

if ( token.equals("innerLevel"){
    presenter = new TopLevelPresenter(eventBus,rpcService,new TopLevelView(),token);
    presenter.go();
}

Now contructor of TopLevelPresenter will through event for creation of MiddleLevel if token.equals("innerLevel")

eventBus.fireEvent(MiddleLevelEvent);

MiddleLevelEvent should contains name of lower level.

again in app controller I will check for history Tokenizer.

if ( token.equals("middleLevel"){
    presenter = new MiddleLevelPresenter(eventBus,rpcService,new MiddleLevelView(),**what to pass here**);
    presenter.go();
}

But I am feeling method I have thought is not good.Can anyone help me to tell what is standard way of using multi level view in GWT application using MVP.

I went the same route as you when I first started working with places but was so glad to find a solution that is well documented by Thomas Broyer. The idea requires a little bit more code but makes your code much cleaner and flexible. You need to create multiple ActivityMappers for different regions of your display. This sounds complex at first but once you try it you will see that it works very nicely for pretty much any kind of layout. The token concept is a novel one but will give you headaches in my experience.

GWT 2.1 Activities – nesting? YAGNI!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM