Add widget to pure html that is not part of DOM-structure yet
extjs, gwt
Solution
Wrap the `div` in an `HTLMPanel`
LineChart lineChart = new LineChart();
HTMLPanel panel = new HTMLPanel(result);
panel.add(lineChart, "whatever");
Problem
Okay, this really gets annoying since I am sure that GWT should support what I want to do. I asked already two times and I searched the web but I just can't find a solution to my problem. What I want to do is to load a textfile from the server that e.g. looks like this: ``` <!-- linear_regression.txt --> <h1>Linear Regression</h1> Welcome to this chapter. Here, have a graph: <div id="whatever"></div> Alright, now have some math stuff: ``` and place a `Widget` - in my case a line chart - into the div `<div id="whatever">`. I tried a few things.. Inside the `onSuccess()` method of an RPC I want to do something like that: ``` public void onSuccess(String result) { HTMLPanel tmp = new HTMLPanel(result); Element el = tmp.getElementById("whatever"); el.appendChild(new LineChart().asWidget().getElement()); contentRoot.add(tmp); } ``` If I do it like that, my result looks like this: ``` <div id="whatever"> <!-- Here I want the chart to be placed but all I get is this: --> <div></div> </div> ``` The other approach looks like this: ``` HTMLPanel tmp = new HTMLPanel(result); contentHome.add(tmp); Element el = RootPanel.get("whatever").getElement(); el.appendChild(new LineChart().asWidget().getElement()); ``` But here I get an uncaught exception: ``` 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) at ew.client.layout.MainLayout$1.onSuccess(MainLayout.java:95) at ew.client.layout.MainLayout$1.onSuccess(MainLayout.java:1) ... ``` I really get sick of this issue. Does anyone know how I can solve this problem?