PDA

View Full Version : [CLOSED] stateful is not initialized properly



mikecar
4 Jun 2010, 12:01 AM
the property "stateful" is not defined in the prototype of Component. however, the tests to check whether a component must iniialize/save state go like this:


if(this.stateful !== false){
this.initState();

since undefined !== false, the result is, if the current state provider contains state info for a component, for whatever reason, the component will initialize its state, even though the property "stateful" is not set.

Fix: initialize the property properly in the base class

Condor
4 Jun 2010, 4:49 AM
Why is this a bug? 'stateful' has always been undefined by default, which is interpreted as 'true'.

IMHO the only thing that needs to be changed is the API docs (stateful default value is missing).

ps. My applications always contains:

Ext.Component.prototype.stateful = false;
And I only set stateful:true on components that actually need it.

mikecar
4 Jun 2010, 5:10 AM
I just added the same line in mine, to work around. the thing is, state is a specialized functionality, which should be enabled by action, and not by default. Also, interpreting "undefined" as true, for something that has positive semantics is IMHO completely wrong. which is my original point. for example, if a component had a property "doNotRender", would you like it to be interpreted as true, if you forget to specify it ?
The fact that you saw the need to initialize the property globally, just proves my point.

evant
4 Jun 2010, 6:24 AM
Well, you're essentially saying that it's a bug that items are stateful by default. Whether this is the case or not... matter for discussion.