It seems to me that the best approach here would be to simply grab the HTML
content on startup, pull it out using innerHTML, then throw it into a new
HTML widget that you can switch out with others. For example:
<...>
<div id='stuff'>
<... stuff ...>
</div>
<...>
Element stuffElem = Document.get().getElementById("stuff");
String html = stuffElem.getInnerHTML();
stuffElem.setInnerHTML("");
RootPanel stuffRoot = RootPanel.get("stuff");
HTML newStuff = new HTML(html);
stuffRoot.add(newStuff);
Then you can do whatever you want with the newStuff widget, including
replace it with other widgets.
On Sun, Sep 21, 2008 at 2:48 PM, Ed <[EMAIL PROTECTED]> wrote:
>
> > RootPanel rp = RootPanel.get("bar");
> > rp.getElement().setInnerHTML("");
> > rp.add(someWidget);
>
> Hellu, I finally upgraded to RC2 and did some testing concerning the
> above.
> I think we overlooked an important thing, something which was the
> original problem:
>
> I want to wrap a piece of existing html code and replace that with
> some GWT created widgets/panels, but also be able to switch back to
> the original html code that was wrapped.
>
> This last remark is an important one, and isn't possible in the above
> solution. That is the call setInnerHTML("") will remove the existing
> html code, such that it can't be shown anymore when I want to switch
> back to it.
> Secondly, I get an attach exception (the one that is mentioned in the
> first post). Why? I do something like this:
>
> RootPanel parent = RootPanel.get("parent");
> HTML child = HTML.wrap(Document.get().getElementById("child"));
>
> <html>
> ...
> <div id="parent">
> <div id="child">
> <p>some content</p>
> ....
> </div>
> </div>
> ....
> </html>
>
> Then I want to set the child as as a child widget of the parent, such
> that I call something like this:
> parent.add(child), which generates an exception as the child is
> already attached.
> But due to erasing the inner content, it doesn't make sense anyway, as
> the child doesn't contain any content anymore :(...
> So bottom line: I can't do the HTML content switching with the current
> GWT widgets as we thought we could.
> Any idea's how I can still do this with the default GWT widgets ?
>
> --
> Ed
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---