简体   繁体   English

使用MVP在GWT中的多级视图中进行历史记录管理

[英]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. TopLevelView包含一系列水平放置的按钮(用作菜单)。单击buttonX-TopLevelView时,它会创建另一个View调用MiddleView,并将其追加到TopView的容器中。 Similary MiddleView has same structure as TopView. 类似的MiddleView与TopView具有相同的结构。 When we click on a buttonY-MiddleView which opens InnerLevel-View. 当我们单击一个按钮Y-MiddleView时,它将打开InnerLevel-View。

Now suppose we call URL : 127.0.0.1:7777/demoapp#innerLevel 现在假设我们调用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. 首先检查appController历史记录Tokenizer中的字符串innerLevel。

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") 现在,如果token.equals(“ innerLevel”),TopLevelPresenter的构造函数将通过事件来创建MiddleLevel

eventBus.fireEvent(MiddleLevelEvent);

MiddleLevelEvent should contains name of lower level. MiddleLevelEvent应该包含较低级别的名称。

again in app controller I will check for history Tokenizer. 再次在应用控制器中,我将检查历史记录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. 但是我感觉到我认为不好的方法。有人可以帮我说一下使用MVP在GWT应用程序中使用多级视图的标准方法是什么。

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. 第一次开始与地方合作时,我走的路与您相同,但很高兴找到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. 您需要为显示的不同区域创建多个ActivityMappers。 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? GWT 2.1活动–嵌套? YAGNI! 亚尼!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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