Thanks Raphael!! I test this and works!! (and find a bug in my code, at first didn't work becouse bind() method there is in constructor, not in start)
In this way I can remove static variable. Thanks a lot Juan 2011/6/12 Raphael André Bauer <[email protected]> > On Sun, Jun 12, 2011 at 9:50 PM, Juan Pablo Gardella > <[email protected]> wrote: > > I can fix with static variables to store like this: > > > There is an onStop() method in activities that is called when > activities are stopped... call a unbind() there and everything is nice > and clean.. > > Cheers, > > > Raphael > > > > > //static variables > > private static HandlerRegistration handlerBoton1; > > ,,, > > > > start(..){ > > ... > > bind(); > > } > > ... > > bind() method: > > > > //Esto lo hacemos para borrar el handler el presenter > anterior. > > if (handlerBoton1!=null) > > handlerBoton1.removeHandler(); > > > > handlerBoton1= vista.getBoton1().addClickHandler( > > new ClickHandler() { > > @Override > > public void onClick(ClickEvent > event) { > > ... > > } > > }); > > > > > > I don't like much, but it works. Is there are other way? Use eventBus > > and @UiHandler don't have this problem, but I must have event > > +eventHandler. > > > > Juan > > > > > > On 12 jun, 12:31, Juan Pablo Gardella <[email protected]> > > wrote: > >> Hi, > >> > >> Recently I have a problem and discover that the cause is about > presenters > >> (activities non singletons) and views singleton. My code is similar to > this: > >> > >> private void bind() { > >> myView.getButton1().addClickHandler(new ClickHandler() { > >> @Override > >> public void onClick(ClickEvent event) { > >> ...}); > >> > >> myView.getButton2().addClickHandler(new ClickHandler() { > >> @Override > >> public void onClick(ClickEvent event) { > >> ... > >> > >> }); > >> } > >> > >> This method is invoque in start() method of the Activity. > >> > >> BUT have a problem this code. Add multiple handlers (one each time an > >> activity start). Then, when I click the botton, the event execute n > times (n > >> times execute start method in activity). So I think this bind() method > is > >> dangerous, the presenter must know if the view is singleton or not. > >> > >> There are a manner to use bind() method in activity and singletons view? > >> > >> Juan > > > > -- > > 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. > > > > > > -- > 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. > > -- 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.
