我非常希望在我的GWT (2.8)应用程序中使用Errai UI(3.2.4)。我已经有了一个带有EntryPoint实现和onModuleLoad的设置。我已经安装了restGWT并与我的服务器(使用Jersey)进行了交互。
我找到的所有文档都假定您正在使用forge插件从头开始构建一个完整的Errai项目。我没有。我只想使用模板和数据绑定。我正在使用一个基本的设置,我甚至不能在我的应用程序中制作标签显示。
我有一个GWT入口点:
public class App implements EntryPoint
{
@Inject
private ApplicationContainer applicationContainer;
public void onModuleLoad()
{
RootPanel.get("root").add(applicationContainer);
}
} 和ApplicationContainer:
@Templated
public class ApplicationContainer extends Composite
{
@DataField
private Element applicationContainer = DOM.createDiv();
@PostConstruct
public void init()
{
GWT.log("Initializing");
}
} 它附带了一个模板:
<div id="applicationContainer" data-field="applicationContainer">
Application Container
</div> 我应该在浏览器中看到"Application Container“,但在浏览器控制台中看到以下错误:
ComplexPanel.java:96未捕获TypeError:无法读取未定义的属性“”removeFromParent__g$“”
小部件和模板的名称相同,并且位于相同的包中。我的小部件的创建方式与文档所示相同:http://erraiframework.org/getting-started/index.html#ErraiUIPage
有人能告诉我我错过了什么吗?这方面的例子非常少,而且它们都假定是一个完整的Errai项目。我还需要一个@入口点吗?我需要@PostConstruct吗?Errai是这样设计的吗?
谢谢你的帮助。
发布于 2016-08-13 15:20:51
是的,@EntryPoint注解很重要,我不确定您是否能够将此框架的一部分与其他方法混淆。这并不意味着你需要使用所有的模块,但对于你使用的部分,你应该遵循Errai的指导方针。
您还可以从路径.../3.2.4.Final/errai-demos/找到更多示例
上面是关于Errai 3.x的。还请注意,如果只是关于Errai UI,则Errai 4.x带来了一些更改。这里有一个很好的描述:http://errai-blog.blogspot.com/2016/04/errai-400beta1-released.html
现在,您的@Templated bean不需要扩展组合。模板的根元素可以作为@DataField访问,等等。
希望它能对你有所帮助。祝好运!
发布于 2016-09-08 09:00:12
你的问题的答案在这里:https://github.com/errai/errai-tutorial
您基本上需要迁移您的应用程序以使用Maven,因此您首先获得正确的依赖项,然后在此项目中使用POM并将其快照到您的项目中。
然后,您可以包含引导程序文件来添加@EntryPoint类,但是这并不是必需的,您只需在客户端路径中添加Page即可,例如:
com.mycompany.app.client
-->MyPage.html
-->MyPage.java这里的java文件包含默认页面,即
@Dependent
@Templated
@Page(role = DefaultPage.class)
public class MyPage extends Composite{}https://stackoverflow.com/questions/38810640
复制相似问题