简体   繁体   English

屏幕布局按位置更改时,使用“活动和位置”的GWT

[英]GWT using Activities and Places when screen layout changes per place

My understanding of GWT's Activities and Places is that for a given region on a screen you have an ActivityManager and an ActivityMapper . 我对GWT的“活动和地点”的理解是,对于屏幕上的给定区域,您具有ActivityManagerActivityMapper You can have multiple regions on the screen which means you can have multiple ActivityManagers and ActivityMappers (one per region). 屏幕上可以有多个区域,这意味着可以有多个ActivityManagersActivityMappers (每个区域一个)。 So, whenever there is a PlaceChange the ActivityManagers ask their respective ActivityMapper what activity it is supposed to be showing given the Place . 因此,只要有PlaceChangeActivityManagers询问其各自的ActivityMapper ,给定Place应该显示什么活动。 This works great as long as your Places all have a common layout that they reuse in different ways to perform different activities. 只要您的所有Places都具有相同的布局,并以不同的方式重复使用以执行不同的活动,此方法就很好用。 My question is how do we handle the case where different Places use radically different layouts? 我的问题是我们如何处理不同Places使用根本不同布局的情况? My first thought is to just have even more ActivityManagers and ActivityMappers , if the Place doesn't use a particular region then the ActivityMapper for that region will simply return null when we change to that Place . 我的第一个想法是只拥有更多的ActivityManagersActivityMappers ,如果Place不使用特定区域,那么当我们更改为Place时,该区域的ActivityMapper只会返回null If there is a better way I would appreciate any wisdom. 如果有更好的方法,我将不胜感激。

I found it much easier to use a single ActivityMapper/ActivityManager pair for the entire app. 我发现在整个应用程序中使用单个ActivityMapper / ActivityManager对要容易得多。

In a typical case you have a "menu" region and a "main" region. 在典型情况下,您有一个“菜单”区域和一个“主”区域。 The menu region is very basic: a click on a menu item sends a user to a new place. 菜单区域非常基本:单击菜单项会将用户转到新位置。 It also highlights the newly selected item and resets the style of the previously selected item. 它还突出显示了新选择的项目并重置了先前选择的项目的样式。 All of this can be easily done in a simple widget that you can include in all views where this menu is required. 所有这些操作都可以通过简单的小部件轻松完成,您可以将其包含在需要此菜单的所有视图中。 Having separate ActivityMapper and ActivityManager for the menu region just complicates everything without providing any benefits. 菜单区域具有单独的ActivityMapper和ActivityManager只会使所有事情变得复杂,而不会带来任何好处。

I use the same approach for "top menu" region and "left menu/tree" region: a widget that tells the presenter which data to show in the "main" region. 我对“顶部菜单”区域和“左侧菜单/树”区域使用相同的方法:一个小部件,告诉演示者在“主”区域中显示哪些数据。

I have over 50 different places in my app, and it really helps to have a simple architecture: each place corresponds to one view and one activity. 我的应用程序中有50多个不同的位置,拥有一个简单的体系结构确实有帮助:每个位置对应一个视图和一个活动。

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

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