PDA

View Full Version : Adding GWT component to another DOM



pjj
19 Aug 2009, 1:10 AM
hi,
is it possible to add a GWT component inside an iframe? I was browsing through the forum for some time and I managed only to retrieve the js reference to the element. Unfortunately, adding any additional components seems to be impossible using this approach. My code:

-- one of the .html's from which I want to access the iframe


(...)
<body>
<iframe src="../shared/header.html" id="header" scrolling="no"></iframe>
(...)
-- header.html


(...)
<body id="header-body">
(...)
<div id="header-section-login"></div>
(...)
<textarea id="test"> zzz </textarea>
(...)
For testing purposes I used textarea to check if I get correct reference. Thus below is working:



IFrameElement frame = IFrameElement.as(RootPanel.get("header").getElement());
com.google.gwt.dom.client.Document document = frame.getContentDocument();
com.google.gwt.dom.client.TextAreaElement textArea = (com.google.gwt.dom.client.TextAreaElement) document.getElementById("test");
textArea.setValue("aaa");
System.out.println(textArea.getValue());
But my goal is to add a Panel to a div inside the header.html and ... below code is improper



HorizontalPanel loginBar = new HorizontalPanel();
document.getElementById("header-section-login").add(loginBar);
Can You help me with this issue?

Thanks,
Pawel

googelybear
24 Aug 2009, 5:28 AM
Hi,
I'm having the same problem (wanting to share some common markup in a header/footer.html and indluce it via iframe). Is there really no solution for this problem? Is there an alternative?