简体   繁体   English

GWT如何工作或者GWT如何将代码加载到app.html文件中?

[英]How does GWT work or rather how does GWT load the code into the app.html file?

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. 我想知道rootPanel (在entryClass中)究竟是什么,以及GWT如何通过rootpanel将Java代码加载到appname.html文件中。 What happens there exactly? 那到底发生了什么? Where is the connection between the rootpanel and the HTML file? rootpanel和HTML文件之间的连接在哪里?

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? 你检查过RootPanel类的来源了吗?

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. 有一个方法RootPanel get(String id)从页面返回元素(well,widget),具体取决于你传入的元素id。如果你没有传递任何东西,例如要求get()get(null)您将收到<body>作为您请求的RootPanel实例。

So, you have your index.html with contents: 那么,你的index.html包含内容:

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

in it. 在里面。

In onModuleLoad() method of your entry class you do 在您的入门类的onModuleLoad()方法中

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. 这将你的新div作为一个孩子添加到最初在html文件中的myPanel div。

Did this help? 这有帮助吗?

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

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