将Errai Ui与GWT一起使用 [英] Use Errai Ui with GWT

查看:64
本文介绍了将Errai Ui与GWT一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'd really like to use Errai UI(3.2.4) in my GWT (2.8) application. I already have one setup with an EntryPoint implementation and an onModuleLoad. I have restGWT setup and interacting with my server (which uses Jersey).

我发现的所有文档均假设您正在构建一个完整的Errai项目,并使用forge插件从头开始.我不是.我只想使用模板内容和数据绑定.我正在使用准系统设置,甚至无法在应用中显示标签.

All of the documentation I find assumes that you are building a full-on Errai project, starting from scratch using the forge addon thing. I'm not. I just want to use the templating stuff and data-binding. I'm working with a barebones setup and I can't even make a label show in my app.

我有这个GWT入口点:

I have this GWT entry point:

public class App implements EntryPoint  
{  
    @Inject  
    private ApplicationContainer applicationContainer;  

    public void onModuleLoad()  
    {  
        RootPanel.get("root").add(applicationContainer);  
    }  
}  

和ApplicationContainer:

And the 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>  

我应该在浏览器中看到应用程序容器",但是在浏览器控制台中出现此错误:

I should see "Application Container" in the browser, but I get this error in the browser console:

ComplexPanel.java:96未捕获的TypeError:无法读取未定义的属性'removeFromParent_0_g $'

ComplexPanel.java:96 Uncaught TypeError: Cannot read property 'removeFromParent_0_g$' of undefined

小部件和模板的名称相同且位于相同的程序包中.我的窗口小部件的创建就像文档所示: http://erraiframework.org/getting-started /index.html#ErraiUIPage

The widget and the template are named the same and in the same package. My widget is created just like the documentation shows: http://erraiframework.org/getting-started/index.html#ErraiUIPage

有人可以告诉我我在这里想念的东西吗?这样的示例非常少,并且都假设了一个完整的Errai项目.我还需要一个@EntryPoint吗?我需要@PostConstruct吗? Errai甚至设计成可以这样工作吗?

Can someone tell me what I'm missing here? Examples for this are very minimal, and they all assume a complete Errai project. Do I still need an @EntryPoint? Do I need @PostConstruct? Is Errai even designed to work like this?

感谢您的帮助.

推荐答案

问题的答案在这里: https://github.com/errai/errai-tutorial

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

You basically need to migrate your app to use Maven so you get the dependencies right first, then use the POM in this project and snap it in your project.

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

Then you can include a Bootstrap file to add a @EntryPoint class however this is not necessary you can just add a Page in the client path e.g.:

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

此处的Java文件包含默认页面,即

Where the java file here contains the default page, i.e.

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

这篇关于将Errai Ui与GWT一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆