如何包含页眉和页脚文件usinig gwt?

时间:2016-10-17 09:27:30

标签: java-ee gwt uibinder

我正在尝试使用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> 

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

你可以这样做:

 <!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文件,你可以include your header.html

您将实例化此类一次,然后更改containerDiv的内容。 containerDiv可以是您想要的任何类型,不必是DeckLayoutPanel