wokier/gwt-mvc

Controller init method called several times?

Closed this issue · 3 comments

I am trying to use gvt-mvt from 0.01 ver.
I tried to upgrate project to the latest version.
It seems there is no way to initialize controller correctly.
Controller class has a private member "initialized".
And abstract method init().
So, as result I can't set initialized to "true" in the init() method 
inplementation.
So, the init() method can be executed several times.



Original issue reported on code.google.com by mkantsu...@gmail.com on 21 Jun 2009 at 9:08

A controller is initialized only when it is called (by browser or user).
As a result, the method 'init' is called, and the boolean marker 'initialised' 
is set 
to true, as this method is only called once.

Extract of the controller class in gwt-mvc 0.2:
 public void call(Event event) {
                if (!initialised) {
                        this.init();
                        initialised = true;
                }
                beginWait(event);
                handleEvent(event);
        }

So you dont have to set the 'initialised' boolean to true, as the framework 
does it 
for you.

Does that answer to your question/issue ?

Original comment by wokier on 22 Jun 2009 at 7:23

  • Changed title: Controller init method called several times?
  • Added labels: ****
  • Removed labels: ****
After some private talk by mail with maxim kantsurov, the prefered way to 
adrress this 
need of 'manual' init, would be to add a method 'doInitIfNecessary' in the 
controller  
that would set the boolean initilised to true and call the 'init' method 
outside of a 
'call'.

Original comment by wokier on 24 Jun 2009 at 12:44

  • Changed state: Started
  • Added labels: ****
  • Removed labels: ****
fixed in 0.3 version

Original comment by wokier on 2 Sep 2009 at 12:27

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****