Are you able to create a custom Widget using UIBinder? When you use an UIBinder with the HTMLPanel you can mix HTML and GWT components:
<g:HTMLPanel> <div id='outerDiv'><h1>Hello text field</h1> <g:TextBox ui:field='myTextField' /></div> </g:HTMLPanel> Each UIBinder Xml file is bound to a Java class. In your Java class you can reference the text box like this: @UiField TextBox myTextField; Since this would be a custom widget you could add and remove to and from other gwt widgets in your project, and by binding the textbox in your Java code you can modify it without impacting the surrounding HTML. On Aug 10, 6:07 pm, "A/C A/C" <[email protected]> wrote: > Is there a way to write some html directly. Add this html to an > existing gwt widget as a child and then wrap the html elements so they > become gwt objects? > > That is: > I want to write something like > > String myHtml=" > <div id='outerDiv'><h1>Hello text field</h1><input type='text' > id='myTextField'></div>"; > > I then want to create a widget with this html, so I do a > new HTML(myString) and add this html widget to my panel. So far so > good, but then I want to wrap myTextField so it become a gwt object, > but if I do a > TextBox.wrap(DOM.getElementById("myTextField"); > I get an > > 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) > > If i understand this correct, I can't wrap an html element if the html > element it is in html that have a parent which is a gwt widget. > > So is there anyway to do what I have tried to describe above? I don't > have to make the html at runtime, so I thought about placing the html > in a display: none block in the page which contain my gwt root panel, > and then use DOM methods to move it to where I wan't it at runtime, > but this still give me the exception above when I try to wrap the html > elements . > > Martin -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
