You found a bug! We've classified it as EXTJS-5080 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    12
    Vote Rating
    0
    rharbers is on a distinguished road

      0  

    Question 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.

    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
                            };
                        },
                    }, ],
                }, ],
            });
        },
    });
    I've seen a suggestion to override the constructor of AbstractComponent, but surely that can't be the way to go with this...

    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:
    Code:
    Ext.override(Ext.AbstractComponent, {
      stateful : false,
    });
    which seems to work, but again, not very elegant.

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,520
    Vote Rating
    375
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    This is definitely a bug and must be fixed. Do you want this thread to be moved to bugs?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #3
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    12
    Vote Rating
    0
    rharbers is on a distinguished road

      0  

    Default


    Sure.

  4. #4
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    12
    Vote Rating
    0
    rharbers is on a distinguished road

      0  

    Default


    So, any news on this bug?

  5. #5
    Sencha User harley.333's Avatar
    Join Date
    Mar 2007
    Posts
    286
    Vote Rating
    4
    harley.333 is on a distinguished road

      0  

    Default


    Any news? I'm using 4.1 RC2.
    harley.333 - Harley Jones
    harley.333@gmail.com - Find me on Google Talk.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi