0

I am using GWT. have below code in my host page.

<div id="mainDiv"/>
 <iframe id="__printingFrame" style="width:0;height:0;border:0"> </iframe> 

in EntryPoint's onModuleLoad() i have below code:

@Override
    public void onModuleLoad() {
        RootPanel.get("mainDiv").add(new SomePage());
    }

in one of the methods of SomePage.java i am doing:

RootPanel rootPanel = RootPanel.get("__printingFrame");
  rootPanel.add(new Html(" "));//adding some widget

But bcaz of above line i am getting below exception. Am i missing anything here?

java.lang.AssertionError: A widget that has an existing parent widget may not be added to the detach list
    at com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose(RootPanel.java:136)
    at com.google.gwt.user.client.ui.RootPanel.get(RootPanel.java:211)

Thanks!

2 Answers2

1

There are 2 issues in your code (but you're only seeing one for now):

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
-1

RootPanel.get("id") can only get <div> element.you can wrap existed element like that.

Frame frame=Frame.wrap(DOM.getElementById("__printingFrame"));
aki miyazaki
  • 493
  • 4
  • 11