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

馋奶兔 提交于 2019-12-12 20:26:39

问题


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.


回答1:


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?



来源:https://stackoverflow.com/questions/13923716/how-does-gwt-work-or-rather-how-does-gwt-load-the-code-into-the-app-html-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!