On Wednesday, August 31, 2011 3:56:12 PM UTC+2, vmrggg wrote:
Sorry. Nobody has time to go through code. I understand that.
Let me try to explain it in another way:
RootPanel rp = RootPanel.get( "DIV_ID" );
rp.add( widget1 );
rp.add( widgetN );
RootPanel.detachOnWindowClose( rp );
detachOnWindowClose is automatically called by RootPanel.get(). It's a method expected to be used in widgets' static wrap(Element) methods. There's little to no reason to call it if you're not writing your own wrap(Element) method for your own widget.
At this point in time the event handlers of widget1 through widgetN works allright.
Later on I need to get rid of this set of widgets and replace then with another one, so I tried the following:
rp.clear(); // To remove widget1 through widgetN
rp.removeFromParent(); // To "unbind" from "DIV_ID"
When you removeFromParent(), given that a RootPanel has no parent and is in the "detach on window close" list, it is detached (RootPanel.detachNow(rp) is called).
The issue is that RootPanel caches RootPanel instances, so a subsequent call to RootPanel.get(String) with the same ID will return the exact same RootPanel instance, but won't re-attach it!
Then I start again (in another part of the code) with a new set of widgets, but using the same "DIV_ID" of the host Html page, but the event handlers of this new set of widgets does not work. If I use another element id of the same host page, say "DIV_ID_2", it works.
There is something completely wrong in my undestanding of the GWT about this point?
Just remove your call to removeFromParent(), there's absolutely no reason to do it on a RootPanel.--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/MO5gnZ3mJd0J.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.