- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 GWT MVP 和 UiBinder 创建一个带有 DockLayoutPanel 的应用程序。我希望南北码头是静态的,包含按钮和链接。我想在中心和东码头的两个不同区域拥有动态 View 。由于这些动态区域应该是相互独立的,所以我为每个动态显示区域设置了不同的 ActivityMapper 和 ActivityManager;中、东上、东下。
加载应用程序时如何独立初始化这3个不同的显示区域?如何在一个显示区域从一个 Activity 切换到另一个而不影响其他区域?
当我使用 PlaceController 的 goTo 在一个区域从一个 Place 切换到另一个 Place 时,另一个区域的 Activity 会停止。
求救,求救,求救!
以下是我的一些代码:
AppViewImpl.ui.xml
<g:DockLayoutPanel styleName="{style.dockPanel}" unit="PX" width="975px" height="100%">
<!-- DOCK PANEL EAST -->
<g:east size="220">
<g:LayoutPanel styleName="{style.eastPanel}">
<g:layer left="0px" width="220px" top="0px" height="105px">
<g:SimpleLayoutPanel ui:field="topRightPanel"/>
</g:layer>
<g:layer left="0px" width="220px" top="110px" height="340px">
<g:InlineLabel styleName="{style.label}" text="ANOTHER DISPLAY AREA"/>
</g:layer>
</g:LayoutPanel>
</g:east>
<!-- DOCK PANEL NORTH -->
<g:north size="110">
<g:LayoutPanel styleName="{style.northPanel}">
<g:layer left="0px" width="755px" top="0px" height="105px">
<g:InlineLabel styleName="{style.label}" text="NORTH PANEL"/>
</g:layer>
</g:LayoutPanel>
</g:north>
<!-- DOCK PANEL SOUTH -->
<g:south size="20">
<g:LayoutPanel styleName="{style.southPanel}">
<g:layer left="0px" width="755px" top="0px" height="20px">
<g:InlineLabel styleName="{style.label}" text="SOUTH PANEL"/>
</g:layer>
</g:LayoutPanel>
</g:south>
<!-- DOCK PANEL CENTER -->
<g:center>
<g:SimpleLayoutPanel ui:field="mainPanel" />
</g:center>
</g:DockLayoutPanel>
private Place defaultPlace = new DefaultPlace("");
public void onModuleLoad() {
// Create ClientFactory using deferred binding so we can replace with
// different impls in gwt.xml
ClientFactory clientFactory = GWT.create(ClientFactory.class);
EventBus eventBus = clientFactory.getEventBus();
PlaceController placeController = clientFactory.getPlaceController();
// Start ActivityManager for the main widget with our ActivityMapper
ActivityMapper topRightActivityMapper = new TopRightActivityMapper(clientFactory);
ActivityManager topRightActivityManager = new ActivityManager(topRightActivityMapper, eventBus);
topRightActivityManager.setDisplay(clientFactory.getAppView().getTopRightPanel());
// Start ActivityManager for the main widget with our ActivityMapper
ActivityMapper mainActivityMapper = new AppActivityMapper(clientFactory);
ActivityManager mainActivityManager = new ActivityManager(mainActivityMapper, eventBus);
mainActivityManager.setDisplay(clientFactory.getAppView().getMainPanel());
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper = GWT .create(AppPlaceHistoryMapper.class);
PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
historyHandler.register(placeController, eventBus, defaultPlace);
RootLayoutPanel.get().add(clientFactory.getAppView());
// Goes to place represented on URL or default place
historyHandler.handleCurrentHistory();
new AppController(clientFactory);
}
public class AppController implements AppView.Presenter {
private ClientFactory clientFactory;
AppController(ClientFactory clientFactory){
this.clientFactory = clientFactory;
goTo(new TopRightAPlace(""));
}
@Override
public void goTo(Place place) {
clientFactory.getPlaceController().goTo(place);
}
}
public class TopRightAViewImpl extends Composite implements TopRightAView {
interface Binder extends UiBinder<Widget, TopRightAViewImpl> {
}
private static final Binder binder = GWT.create(Binder.class);
private Presenter listener;
@UiField
Button button;
public TopRightAViewImpl() {
initWidget(binder.createAndBindUi(this));
}
@Override
public void setName(String name) {
button.setHTML(name);
}
@Override
public void setPresenter(Presenter listener) {
this.listener = listener;
}
@UiHandler("button")
void onButtonClick(ClickEvent event) {
listener.goTo(some other place);
}
}
最佳答案
GWT Place
年代,PlaceController
, 和 PlaceHistoryMapper
使您能够在应用程序中创建可添加书签的 URL,从而允许浏览器的后退按钮和书签按预期工作。这就是 GWT Place
s 专为。因此,拥有多个 Place
是没有意义的。由于您拥有整个应用程序的一个 URL,因此您可以随时在应用程序中激活。PlaceController
的goTo()
方法确实通知注册的ActivityManager
,在接收到 PlaceChangeEvent 时停止当前 Activity。
我对你的建议是不要使用 Place
s 和 PlaceChangeEvent
s 代表您的DockLayoutPanel
东侧的两个区域.使用Place
s 代表您的应用程序的主屏幕,它可能是您的 DockLayoutPanel
的中心.火不同GwtEvent
类型,可以是通用事件类型之一(即 ValueChangeEvent
)或自定义事件类型,当您需要更新东侧区域时。您仍然可以使用 Activitie
s 用于东侧,但您需要创建自己的 ActivityManager
,这实际上并不难。你所要做的就是复制GWT的ActivityManager
,重命名它,并替换处理 PlaceChangeEvent
的方法的名称s 和 PlaceChangeRequestEvent
s 与那些处理您自己的事件的人。
关于gwt - 如何: UiBinder + GWT MVP + multiple independent display areas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8244851/
简单的例子。我在 UiBinder 中声明了 2 种样式: .success { font-size: 13px; margin: 15px;
我在 GWT 项目中使用 UiBinder xml 文件。问题是 Eclipse 没有给我任何关于我可以与小部件一起使用的属性的信息 例如,我知道我可以这样设置宽度或样式: 但是在点击 ctrl +
我想知道是否有一种方法可以将 gwt uibinder 逻辑构建到抽象父类中,这样我就不必在每个要绑定(bind)的类中重复代码。 例如,我希望能够做这样的事情: public abstract cl
如何在 GWT 中的 UiBinder 中定义 TabPanel。 TabPanel 和 TabLayoutPanel 有什么区别。在哪里可以找到有关 TabPanel uibinder 参数的其他信
我想在带有两个选项卡的选项卡面板的主体内放置一些 anchor 。但是我的 anchor 不可见。代码如下 Analysis Person
我正在尝试使用 uiBinder。我按照提供的教程 谷歌,但我不知道为什么 clickevent 不起作用?我想计算点击次数并在跨度中显示它,它不起作用,我也放了 window.alert 但似乎根本
这张图片正在显示,但无论我使用的宽度或高度值如何,我都无法调整它的大小。有什么想法吗?谢谢。 .fortaImage { width:'50px'; height:'50p
我正在使用 Eclipse Ganymede 3.4 版开发 GWT2.3。使用 UIBinder 时,自动完成功能(建议)非常慢。 在这种情况下我不知道该怎么办。我需要添加一些插件或文件。工作太慢了
我们在我们的项目中使用 GXT 和 GWT(2.4)。我们正在使用 UIBinder 进行页面设计。目前我们面临太多问题,无法在 xml 页面中编写代码。自动建议花费太多时间(当我们按 ctl+Spa
类(class) Foo有一个变量 List bar ,如何使用 UiBinder 渲染每个按钮?甚至可能吗? 最佳答案 UiBinder 是一个 XML 模板 用于声明式布局小部件和不是渲染器 .因
我刚刚创建了小部件: public class myWidget extends FlowPanel { private T value; public T getValue() { retu
我想通过 GWT 2.0 中的 UiBinder 使用声明性方法来实现菜单(MenuBar、MenuItem)。 我遇到了两个问题: 有没有办法在 .ui.xml 文件中添加 MenuItemSepa
我在输入时遇到此错误 在我的 UiBinder 文件中,错误是: [DEBUG] [MyGWT] - Rebinding com.mycomp.mygwt.client.Resources [
在提出问题之前,我将简要描述一下背景。我有一个 Widget 类,它将 ui 实现“外包”到一个单独的类(如下所示): public class SimpleFilmWidget extends Co
我正在为我的应用程序使用 GWT 和 UiBinder,我正在尝试这样做 但是自定义placeholder属性将不起作用,因为没有 setPlaceholder TextBox 上的方法- 我需要这
在 GWT + UiBinder 中,您可以像这样捕获点击: @UiHandler("cancelButton") void onCancelButtonClicked(ClickEvent e) {
我想在带有 uiBinder 的 GWT 中使用链接或按钮,例如 (a href="..."/>)。 我找到了“超链接”小部件,但我不知道如何使用它。 最佳答案 您应该使用 Anchor小部件。 您可
我正在创建一个带有标签和文本框的复合 uibinder 小部件。 预期用途是: The text to be put in the box. 我找到了如何使用自定义 @UiConstruc
我无法让 CSS 图像 Sprite 出现在 GWT UiBinder 中。我做了评论 how do i use image sprites in GWT? ,但发现我已经在做建议的事情了。 我有一个
我正在尝试在 GWT UIBinder 中实现一个简单的基于 CSS 的菜单,但我在某个特定部分遇到了一些困难。 菜单有两个主要级别的项目:“新 session ”和“当前 session ”。当用户
我是一名优秀的程序员,十分优秀!