gpt4 book ai didi

eclipse - GWT:对多个页面使用相同的 UI 模板?

转载 作者:行者123 更新时间:2023-12-04 23:32:50 25 4
gpt4 key购买 nike

如何将相同的 UI 模板(*.ui.xml 文件)与从 Composite 扩展的多个 Java 对象一起使用?

我需要构建几个页面,这些页面应该以相同的布局显示基本相同的信息,但在一个页面上,某些字段是可编辑的,而在另一个页面上,其他字段是可编辑的。我想在 ui.xml 中只指定一次布局,并在不同的 *.java 类中创建不同的行为。

Eclipse 给我一个语法错误“FirstAppUI.ui.xml is missing”

@UiTemplate("Template.ui.xml")
public class FirstAppUI extends Composite {
interface FirstAppUIUiBinder extends
UiBinder<Widget, FirstAppUI> {
}
}


谢谢!
简·普鲁萨科娃

最佳答案

我认为您需要放置 @UiTemplate Binder上的注释,不上Composite类(class)

这段代码对我有用:

public class TestUiBinder extends Composite {

@UiTemplate("SomeTemplate.ui.xml")
interface TestUiBinderUiBinder extends UiBinder<Widget, TestUiBinder> {}
private static TestUiBinderUiBinder uiBinder = GWT.create(TestUiBinderUiBinder.class);

public TestUiBinder() {
initWidget(uiBinder.createAndBindUi(this));
}
}

public class AnotherTestUiBinder extends Composite {

@UiTemplate("SomeTemplate.ui.xml")
interface TestUiBinderUiBinder extends UiBinder<Widget, AnotherTestUiBinder> {}
private static TestUiBinderUiBinder uiBinder = GWT.create(TestUiBinderUiBinder.class);

public AnotherTestUiBinder() {
initWidget(uiBinder.createAndBindUi(this));
}
}

这似乎有点类似于 applying different templates to the same widget 的解决方案.

关于eclipse - GWT:对多个页面使用相同的 UI 模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2632461/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com