Suresh Atta
Suresh Atta

Reputation: 121998

How to wrap whole GWT in div?

Trying to make design

-----------
header(xyz.html)
-----------
content(GWT module)
-----------
footer(xyz.html)
-----------

What I done is

<div id=header>....</div>
<div id="container">
     <script type="text/javascript" language="javascript" src="spw/spw.nocache.js"></script>
</div>
<div id="footer"></div>

But , It's always appears screen in as

----
header
----
footer
-----
gwt content (I saw in firebug that this is in a iframe)
-------

What should I do to get the GWT content exactly in the content area? Am I need to apply any css ?? Or am I missing something here?

Upvotes: 1

Views: 228

Answers (1)

Braj
Braj

Reputation: 46841

Add root widget in container div by calling below method in onModuleLoad() method of your Entry point class

RootPanel.get("container").add(root_widget);

nocache.js just loads GWT compiled js into browser. Placement of component is not driven by the position of nocache.js in your html/jsp file.

Its good to place nocache.js in head section.

Sample code:

<html>
<head>
<title>Title</title>
<script type="text/javascript" language="javascript"
    src="spw/spw.nocache.js"></script>
</head>
<body>
    <div id=header>....</div>
    <div id="container"></div>
    <div id="footer">...</div>
</body>
</html>

EDIT

Actually I looked for a solution without touching that RootPanel. But there is other way around

Try any one option:

Document

import com.google.gwt.dom.client.Document;

Document.get().getElementById("container").appendChild(rootWidget.getElement()); 

JSNI

getElementById("container").appendChild(rootWidget.getElement());

public static final native Element getElementById(String id) /*-{
    return $wnd.document.getElementById(id);
}-*/;

Upvotes: 3

Related Questions