-
9 Dec 2011 4:02 AM #1
State providers not restoring state
State providers not restoring state
(posted this earlier in the community Q&A forum, before we had a support license)
Hi,
I'm trying to save the state of some components in a cookie (particularly checkboxes, but it could be anything later on). However, I have a hard time getting it to correctly initialize the checkbox when reloading the application: it seems AbstractComponent adds a stateEvent listener for the resize event, causing the component to save it's state ("unchecked") *before* it's state has been restored.
So, it correctly saves it's state to the cookie, but when I reload the page in my browser, it doesn't restore it, because it's overwritten before it gets a chance to.
I've seen a suggestion to override the constructor of AbstractComponent, but surely that can't be the way to go with this...Code:Ext.application({ launch : function() { Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider')); Ext.create('Ext.container.Viewport', { layout : 'fit', items : [ { xtype : 'form', items : [ { xtype : 'checkbox', stateful : true, stateId : 'testbox', stateEvents : [ 'change', ], getState : function() { return { checked : this.checked }; }, }, ], }, ], }); }, });
Another thing that bothers me is that the default value of the "stateful" property is true. This means that by just adding a state provider, all kinds of components suddenly start storing and restoring their state, even components that have been generated by others, so I don't have control over their state behaviour. This can be remediated by overriding the stateful property of all components:
which seems to work, but again, not very elegant.Code:Ext.override(Ext.AbstractComponent, { stateful : false, });
-
11 Dec 2011 11:09 AM #2
This is definitely a bug and must be fixed. Do you want this thread to be moved to bugs?
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
11 Dec 2011 11:31 PM #3
-
11 Jan 2012 5:59 AM #4
-
17 Apr 2012 6:12 PM #5
Any news? I'm using 4.1 RC2.
harley.333 - Harley Jones
harley.333@gmail.com - Find me on Google Talk.
You found a bug! We've classified it as
EXTJSIV-5080
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote