MVP pattern problem with singletons views

2011-06-12 Thread Juan Pablo Gardella
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) { ... });

Re: MVP pattern problem with singletons views

2011-06-12 Thread Juan Pablo Gardella
I can fix with static variables to store like this: //static variables private static HandlerRegistration handlerBoton1; ,,, start(..){ ... bind(); } ... bind() method: //Esto lo hacemos para borrar el handler el presenter anterior. if (handlerBoton1!=null)

Re: MVP pattern problem with singletons views

2011-06-12 Thread Raphael André Bauer
On Sun, Jun 12, 2011 at 9:50 PM, Juan Pablo Gardella gardellajuanpa...@gmail.com 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,

Re: MVP pattern problem with singletons views

2011-06-12 Thread Juan Pablo Gardella
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 raphael.andre.ba...@gmail.com On Sun, Jun 12, 2011

Re: MVP pattern problem with singletons views

2011-06-12 Thread Thomas Broyer
Don't forget the onCancel() method too: if your activity starts asynchronously, it can be cancelled before you set the view in the AcceptsOneWidget passed in argument to the start() method; in this case, onCancel() is called rather than onStop(). You'll find out that it's much easier to handle

Re: MVP pattern problem with singletons views

2011-06-12 Thread Juan Pablo Gardella
Hi Thomas!! Thanks for the info. I fixed my code. Juan On 12 jun, 15:47, Thomas Broyer t.bro...@gmail.com wrote: Don't forget the onCancel() method too: if your activity starts asynchronously, it can be cancelled before you set the view in the AcceptsOneWidget passed in argument to the