On Dec 29, 5:06 am, jd <[email protected]> wrote:
> Hi,
>
> I have a page that contains a header div containing some anchors
> defined in the html page.  My GWT code finds the header with
> RootPanel.get(String) and adds it to a DockLayoutPanel.  I have tried
> to attach click handlers to the links in the header like this:
>
>                 header = RootPanel.get("header");
>                 NodeList<com.google.gwt.dom.client.Element> aes = 
> header.getElement
> ().getElementsByTagName("a");
>                 com.google.gwt.dom.client.Element item = aes.getItem(0);
>                 Anchor anchor = Anchor.wrap(item);
>                 anchor.addClickHandler(new ClickHandler()
>                 {
>                         public void onClick(ClickEvent event)
>                         {
>                                 Window.alert("hi");
>                         }
>                 });
>
> but get this 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.Anchor.wrap(Anchor.java:59)
>
> Can anyone suggest how I should be approaching this situation?

Use Document.get().getElementById("header") instead of RootPanel.get
("header").getElement() to avoid the RootPanel widget being created,
which then prevents wrap()ing an inner element in another widget.

--

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