Search code examples
jakarta-eegwtuibinder

how to include header and footer files usinig gwt?


I'm trying to create a webApplication with gwt and my idea is to make a header and footer files to be included in all pages. I tried to use the UiBinder for this but it dosen't work.

 <!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> 

Any idea ?


Solution

  • You could do something like this:

     <!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> 
    

    EDIT: to include a html file you could just include your header.html.

    You would instantiate this class once and then change the content of containerDiv. containerDiv can be of whatever type you want, doesnt has to be a DeckLayoutPanel.