GWT如何工作,或者GWT如何将代码加载到app.html文件中? [英] How does GWT work or rather how does GWT load the code into the app.html file?

查看:96
本文介绍了GWT如何工作,或者GWT如何将代码加载到app.html文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 rootPanel (它在entryClass中)究竟是什么,以及GWT如何通过rootpanel将Java代码加载到appname.html文件中。
究竟发生了什么?
在rootpanel和HTML文件之间的连接在哪里?



我找不到任何详细解释这个过程的方面。如果有人能解释它或发送一些好的链接到解释这个问题的网站,这将是非常有帮助的。

你有没有检查 RootPanel 类的源代码



有一个方法 RootPanel get(String id ),它根据你传入的元素ID从页面返回元素(井,小部件)。如果你不传递任何东西,例如要求 get() get(null)您将收到< body> 作为您请求的RootPanel实例。



所以,你有你的index.html内容:

  <身体GT; 
< div id =myPanel>< / div>
< / body>

其中。



onModuleLoad()您的入门类的方法

  FlowPanel myNewDiv = new FlowPanel (); 
//为myNewDiv添加一些样式,更多元素和事件处理函数
// ...
RootPanel.get(myPanel)。add(myNewDiv);

它将您的新div添加为 myPanel div最初是在html文件中。



这有帮助吗?


I would like to know what the rootPanel (which is in the entryClass) exactly is, and how GWT loads the Java code into the appname.html file via rootpanel. What happens there exactly? Where is the connection between the rootpanel and the HTML file?

I could not find any side which explains this process in a detail. It would be very helpful if somebody could explain it or send some good links to websites which are explaining this issue.

解决方案

Have you checked the sources for RootPanel class?

There is a method RootPanel get(String id) that returns element (well, widget) from the page depending on the element id you pass in. If you don't pass anything and for example ask for get() or get(null) you will receive <body> as your requested RootPanel instance.

So, you have your index.html with contents:

<body>
<div id="myPanel"></div>
</body>

in it.

In onModuleLoad() method of your entry class you do

FlowPanel myNewDiv = new FlowPanel();
// add some styles, more elements and event handlers to myNewDiv
// ...
RootPanel.get("myPanel").add(myNewDiv);

Which adds your new div as a child to myPanel div which was originally in the html file.

Did this help?

这篇关于GWT如何工作,或者GWT如何将代码加载到app.html文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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