Hi,

Widgets are added to widgets, elements are added to elements.
If you want to put a widget into the dom, I'd use a RootPanel, since
it will take care of the unloading that is needed:

p = RootPanel.get(currentElement.getId());
p.add(someWidget);

if currentElement doesn't have an Id, you could use
  currentElement.setId(DOM.createUniqueId());
to set one.

Note that these are Elements, not Nodes; not every node is an element,
and not every node is allowed to have children (which is probably why
the appendChild fails, but without more information then "an
exception" it is hard to be sure).

Gert

On Jun 10, 11:51 pm, peterk <[email protected]> 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 <[email protected]> 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 [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
-~----------~----~----~----~------~----~------~--~---

Reply via email to