You need to make sure that your node is an element. also .wrap() is not found in widget itself but rather in its subclasses (Label for instance)
-jason On Jun 10, 2009, at 3:51 PM, peterk wrote: > > Hey Jason, > > Thanks for your reply! > > I'm afraid I'm still running into problems here. First, even just > trying to insert an element. I have this code: > > SpanElement test_element = Document.get().createSpanElement(); > test_element.setInnerText("Hello there"); > currentNode.appendChild(test_element); > > currentNode is of type Node. This compiles OK, but at run time I get > an exception on the appendChild call. > > How can I add or append an element to a node like this? > > Secondly..I can't seem to find any wrap method in the Widget class? > > Any further insight would be greatly appreciated..thanks so much! > > On Jun 10, 8:41 pm, Jason Essington <jason.essing...@gmail.com> wrote: >> Probably the safest thing to do would be to insert an element, then >> use the widget's .wrap() method to "promote" that element to a >> widget. >> >> there are other ways, but they are prone to leaking memory. >> >> -jason >> >> On Jun 10, 2009, at 1:36 PM, peterk wrote: >> >> >> >>> Hey all, >> >>> I'm walking the DOM tree and would like to append a Widget to >>> certain >>> nodes where certain conditions are met, but I'm not having much >>> success. >> >>> appendChild expects a Node as its parameter, so I can't just >>> append a >>> type of Widget. It will accept Widget.getElement() as a parameter, >>> but >>> this leads to runtime errors. >> >>> Is it possible to mix Widgets with the DOM like this or is the only >>> way to add Widgets to a page via the RootPanel.get() ..? If so is >>> there a way to add Widgets to the page based on a desired position >>> in >>> the DOM? >> >>> I'd like to use a custom widget I've made, having everything wrapped >>> neatly in a class, and not have to revert to lower level stuff.. >> >>> Thanks for any help :) > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---