Re: Destroy a widget
I can't really understand what you are asking or saying. If you want the widget to remain visible but to stop receiving events, do what Jens said: suppress the event handling logic in the event handler. If you want the widget to stop being visible and to stop receiving events, just do what I said: remove the widget from it's container. and yes, javascript also has garbage collection otherwise every web application would be one giant memory leak -- 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/-/zfufHmcP2kgJ. 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.
Re: Destroy a widget
El lunes, 29 de octubre de 2012 21:46:34 UTC+1, Jens escribió: > > When you create two HelloWorld widgets each of them receives its own > events. If you use @UiHandler in your UiBinder widget and you want to stop > receive events for a widget without removing the widget itself from the > parent (for whatever reason) you have to "disable" your @UiHandler > implementation. > > So you would end up having > > @UiHandler(...) > void onEvent(...) { > if(handleEvents) { > //do your event logic > } > } > > or you use a Delegate interface that a class can implement and that > contains your event logic implementation: > > @UiHandler(...) > void onEvent(...) { > if(delegate != null) { > delegate.onEvent(); > } > } > > In that case you would disable your events by nulling your delegate: > widget.setDelegate(null) > > > Otherwise you have to remove the widget from the parent. > > > -- J. > Thanks for you answer. But "to remove the widget from the parent." doesn`t avoid to receive events ( or my tests were wrong ) -- 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/-/IVFyiGlLNL0J. 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.
Re: Destroy a widget
> > If you want to "destroy" h1, and have it stop reacting to events, simply > remove it from the dom and ensure it is garbage collected (ie. set your > reference to null): > > panel.remove(h1); > h1 = null; > Thanks Garbage collected? I thought that we were in a Javascript world Setting to null doesn't work like I want because it's Javascript code. And I don't want to remove it from a panel , but "destroy it" as entity. Maybe that doesn't have any sense, because I don't know how is implemented by GWT compiler into Javascript code, but h1=null doesn`t work for me -- 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/-/OrUpgQgS5hAJ. 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.
Re: Destroy a widget
When you create two HelloWorld widgets each of them receives its own events. If you use @UiHandler in your UiBinder widget and you want to stop receive events for a widget without removing the widget itself from the parent (for whatever reason) you have to "disable" your @UiHandler implementation. So you would end up having @UiHandler(...) void onEvent(...) { if(handleEvents) { //do your event logic } } or you use a Delegate interface that a class can implement and that contains your event logic implementation: @UiHandler(...) void onEvent(...) { if(delegate != null) { delegate.onEvent(); } } In that case you would disable your events by nulling your delegate: widget.setDelegate(null) Otherwise you have to remove the widget from the parent. -- J. -- 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/-/U0eTr0jdQ9wJ. 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.
Re: Destroy a widget
Sorry there is a typo there. GWT.getRoot().add(panel); should be RootPanel.get().add(panel); -- 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/-/U6PTh3qWnIkJ. 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.
Re: Destroy a widget
I presume by uibinder owner you mean your HelloWorld class overrides the onEvent() method, is that correct? I also presume that you have some other component that is using the HelloWorld objects and attaching them to the view. For example, in your EntryPoint: HelloWorld h1 = new HelloWorld(); HelloWorld h2 = new HelloWorld(); FlowPanel panel = new FlowPanel(); panel.add(h1); panel.add(h2); GWT.getRoot().add(panel); If you want to "destroy" h1, and have it stop reacting to events, simply remove it from the dom and ensure it is garbage collected (ie. set your reference to null): panel.remove(h1); h1 = null; -- 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/-/o6TIayyZhVIJ. 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.
Destroy a widget
Hi: I use GWT 2.3 and this question may sound a little bit weird I create a Widget component calling initWidget(uiBinder.createAndBindUi(this)) into uibinder owner constructor method. public HelloWorld() { initWidget(uiBinder.createAndBindUi(this)); } Therefore, uibinder owner implements onEvent() to receive events When I invoke 'new HelloWorld()' , a new Widget I don't know how GWT implements if I call many times 'new HelloWorld()' , but if a event is fired , is received by all of them. I'd like that if I do HelloWorld h1 = new HelloWorld(); HelloWorld h2 = new HelloWorld(); I could "to destroy" h1 such as when I do h1 = null in Java language, so new fired events only be received by h2 is it possible ? I don't want to remove from parent , I want to destroy that reference , but I don't know how GWT implements it Thanks & regards -- 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/-/iRnebZ6UkTwJ. 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.