我试图用gwt创建一个webApplication,我的想法是使页眉和页脚文件包含在所有页面中。我试着使用UiBinder,但它不工作。
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:DockLayoutPanel unit="EM">
<g:north size="5">
<!-- I want to include my heaader file here -->
</g:north>
</g:DockLayoutPanel>
</ui:UiBinder>
你可以这样做:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:DockLayoutPanel unit="EM">
<g:north size="5">
<!-- I want to include my heaader file here -->
<g:HTML ui:field="header">
<OBJECT data="file_to_include.html">
Warning: file_to_include.html could not be included.
</OBJECT>
</g:HTML>
</g:north>
<g:center>
<g:DeckLayoutPanel ui:field="containerDiv" height="100%" width="100%" animationDuration="900" />
</g:center>
</g:DockLayoutPanel>
</ui:UiBinder>
编辑:要包含一个html文件,你可以只包含你的header.html。
您将实例化该类一次,然后更改containerDiv
的内容。containerDiv
可以是你想要的任何类型,不一定是DeckLayoutPanel
。