quarks
quarks

Reputation: 35276

Inserting a DIV in a GWT Panel

I have this DIV on my application jsp page which I need to "inject" in to a GWT VerticalPanel. Coded on top of the iframe tag which contains "__gwt_historyFrame" :

index.jsp

<div class="footer" id="footer" style="display:none">
        <p>Copyright © 2012 MyCompany. All Rights Reserved.</p> 
        <a href="#">FAQ</a>
        <a href="#">Privacy</a>
        <a href="#">API</a>
        <a href="#">Contact Us</a>
</div>

I am inserting the DIV to the view with this code:

DivElement footer = (DivElement) document.getElementById("footer");
verticalPanel.getElement().appendChild(footer);

However it does not show up, although the getElementById does not return null

What is the correct way to do this?

Upvotes: 0

Views: 2626

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

There are 2 things:

  • you have to remove the display: none of the footer: footer.getStyle().clearDisplay()
  • VerticalPanel is an HTML table, and adding a div to a table is likely to not work.

If I were you, I'd rather use HTML.wrap(footer) or HTMLPanel.wrap(footer) and add that widget to the VerticalPanel, as a widget.

Upvotes: 1

Related Questions