繁体   English   中英

使用Errai Ui和GWT

[英]Use Errai Ui with GWT

我真的很想在我的GWT(2.8)应用程序中使用Errai UI(3.2.4)。 我已经有一个使用EntryPoint实现和onModuleLoad的设置。 我有restGWT设置并与我的服务器(使用Jersey)进行交互。

我发现的所有文档都假定您正在构建一个全面的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_0_g $'

窗口小部件和模板在同一个包中命名相同。 我的小部件就像文档展示一样创建: http//erraiframework.org/getting-started/index.html#ErraiUIPage

谁能告诉我我在这里失踪了什么? 这方面的例子很少,他们都假设一个完整的Errai项目。 我还需要@EntryPoint吗? 我需要@PostConstruct吗? Errai甚至设计成这样工作吗?

谢谢你的帮助。

是的, @EntryPoint注释很重要,我不确定你是否能够将这个框架的一部分与其他方法混淆。 这并不意味着您需要使用所有模块,但如果您使用的部件,您应该遵循Errai的指导原则。

请在此处查看示例入口点: https//github.com/errai/errai/blob/3.2.4.Final/errai-demos/errai-jpa-demo-todo-list/src/main/java/org/jboss /errai/demo/todo/client/local/ClientEntryPoint.java

您还可以从路径中找到更多示例... / 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不需要扩展Composite。 模板的根元素可以作为@DataField等访问。

希望你会发现它有用。 祝好运!

您的问题的答案如下: https//github.com/errai/errai-tutorial

您基本上需要迁移您的应用程序以使用Maven,以便首先获得依赖项,然后在此项目中使用POM并将其捕捉到项目中。

然后,您可以包含一个Bootstrap文件来添加@EntryPoint类,但是这不是必需的,您只需在客户端路径中添加一个Page ,例如:

com.mycompany.app.client
-->MyPage.html
-->MyPage.java

这里的java文件包含默认页面,即

@Dependent
@Templated
@Page(role = DefaultPage.class)
public class MyPage extends Composite{}

暂无
暂无

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

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