GWT 2.1 MVP(活动/地点)和选项卡式显示

发布于 2024-10-15 11:17:36 字数 434 浏览 6 评论 0原文

在现有项目中,我们相当好地使用了 MVP(手工制作)。它被理解并且主要满足我们的需要。对于一个新项目,我正在考虑使用 GWT 2.1(活动和地点)中内置的 MVP 框架。

我们的应用程序大多是选项卡式显示,每个选项卡绑定到单个视图小部件。

我尝试使用“活动”和“地点”来进行此类显示,但没有成功。部分问题在于,Hello World 示例文章最终让我陷入困境,太多新概念让我的大脑无法消化。

IMO 中的 Hello World 示例并不是一个充分的介绍,并且没有处理许多现实世界的用例。我希望有人能给我指出任何使用 MVP 进行选项卡显示的示例应用程序的方向。托马斯·布罗耶(Thomas Broyer)在他的博客上有一些优秀的帖子,但这些仍然让我有点困惑。

以前,我使用 AppController 来处理选项卡更改和每个选项卡的单个演示者。 GWT 2.1 中的新架构让我更加困惑。

On an existing project we’re using MVP (hand crafted) reasonably well. It’s understood and does mostly what we need. For a new project I'm looking at using the MVP framework built into GWT 2.1 (Activities and Places).

Our applications are mostly tabbed displays with each tab bound to a single view widget.

I’ve tried to use Activities and Places without success for this type of display. Part of the problem is that the example Hello World article ended up leaving me chasing my tail, too many new concepts for my brain to digest.

The Hello World sample IMO is not a sufficient introduction and doesn’t deal with many of the real world use cases. I was hoping someone could point me in the direction of any sample applications that use MVP for tabbed displays. Thomas Broyer has some excellent posts on his blog but these have still left me a little perplexed.

Previously I’ve used an AppController to handle tabs changes and single presenters for each tab. The new architecture in GWT 2.1 leaves me more confused that it should.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若相惜即相离 2024-10-22 11:17:36

我正在使用 gwt 活动/地点框架进行选项卡式显示,它效果很好,但是:我决定放弃我们一直在使用的 TabLayoutPanel 小部件并创建我自己的导航栏(看起来像选项卡) )和内容窗格。效果是相同的 - 看起来相同 - 但实现更加简洁。

我认为问题在于尝试将“活动/地点”(有自己的导航理念)与“TabPanel”(有另一种导航理念)混合起来。起初,我尝试将它们放在一起,覆盖选项卡按钮行为以触发 PlaceController,后者反过来切换选项卡,但是......这很混乱。借助独立的导航栏/内容窗格,PlaceController 可以按照自己的意愿完成所有操作。您只需手动切换视图,而不是让 TabPanel 为您完成此操作。

I'm using the gwt Activities/Places framework for a tabbed display, and it works great, BUT: I decided to abandon the TabLayoutPanel widget we had been using and create my own navbar (that looks like tabs) and a content pane. The effect is the same - it looks identical - but the implementation is much cleaner.

I think the problem is in trying to mix Activities/Places, which has its own idea of navigation, with a TabPanel, which has another idea of navigation. At first I tried to throw them together, overriding tab button behavior to trigger a PlaceController, which in turn switched the tabs around, but... it was messy. With the independent navbar / content pane, the PlaceController could do everything just like it wanted to. You just have to manually switch the views, instead of letting a TabPanel do it for you.

戏蝶舞 2024-10-22 11:17:36

我也遇到了这个问题,但设法使用每个选项卡一个活动来使其工作,并且每个活动使用演示者(或更多)来显示选项卡的组件。

关于 Riley Lark 找到的解决方案,我选择使用 Decorator 模式,因此保留了原始的 TabbedPanel。如何 ?每个活动都会注入 (GIN) 一个包含 TabbedPanel 装饰器的演示者。

因此,例如:

  • Tab1Activity 注入 Tab1Presenter,而 Tab1Presenter 又注入 Tab1Decorator,Tab1Decorator 用 Tab1ContentPanel 装饰 TabbedPanel(此面板包含要在 Tab1 选项卡上显示的所有小部件)

  • Tab2Activity 被 Tab2Presenter 注入,反过来,注入 Tab2Decorator,它用 Tab2ContentPanel 装饰同一个 TabbedPanel(此面板包含要在 Tab2 选项卡上显示的所有小部件)

看起来很复杂,但是在创建第一个装饰器之后,它确实得到了回报,我能够保留 TabbedPanel 并利用隐式 URL 历史记录管理在框架中。

I also faced this problem but managed to make it work using one activity per Tab and each activity using a presenter (or more) to display the components of the tab.

Regarding the solution found by Riley Lark, I, instead, opted by using a Decorator pattern and, so, keep the original TabbedPanel. How ? Each activity gets injected (GIN) a presenter that contains a decorator for the TabbedPanel.

So, for example:

  • Tab1Activity gets injected with Tab1Presenter, which, in turn, gets injected with Tab1Decorator which decorates the TabbedPanel with a Tab1ContentPanel (this panel contains all the widgets to be displayed on the Tab1 tab)

  • Tab2Activity gets injected with Tab2Presenter, which, in turn, gets injected with Tab2Decorator which decorates the same TabbedPanel with a Tab2ContentPanel (this panel contains all the widgets to be displayed on the Tab2 tab)

Seems complex but, after creating the first decorator, it really paid off and I was able to keep the TabbedPanel and take advantage of the URL history management implicit in the framework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文