Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    cache issue in using the SmartGwt ListGrid Offline storage while switching versions

    Hi,
    We are using Smart Gwt-4.1p(23rd May 2014)
    Browser : IE10, 11, Google Chrome:37.0.2062.124 m

    With the help of the listGrid unique id I am storing the state of the listGrid in the offline storage. I am using the package com.smartgwt.client.util.Offline to store the state of the listGrid. Now after storing the state of the listGrid in version1 of my software, when I upload a new version which isversion2,some how the listGrid state was not changing. It was using the state of version1 though I have uploaded a new version2 with new compiled smart GWT modules. But, when I clear the browser cache I am able to get the new state of the ListGrid. My questions is:

    Is there any way to get the new state of the ListGrid without clearing the browser cache when I upload a new version?

    please check the sample code form the below
    Code:
    public abstract class WebUIListGrid extends ListGrid {
        protected GroupTypeInfo groupTypeInfo;
        public final FieldNames fieldNames = FieldNames.getInstance();
        public ResourceString resourceString = null;
    
        // Constructor of the WebUIListGrid
        public WebUIListGrid(GroupTypeInfo groupTypeInfo) {
            resourceString = ResourceString.getInstance();
            this.groupTypeInfo = groupTypeInfo;
            this.groupId = groupTypeInfo.getGroupId();
            setListGridProperties();
        }
    
        /**
         * set basic properties
         */              
        private void setListGridProperties() {
           // This Id is used for the offline storage
            setID(getListGridId() + groupId);
            addListGridField();
            // Code to add the dataSorce
            addDS();
            // This will apply the state of the field using the offline storage
            applyFieldState();
        }
    
        /**
         * store list grid column fields in off line     
         */
        public void storeFieldState(){
            // Here I am storing the state of the listGrid.
            Offline.put(getListGridId(), getViewState());
        }
    
    
        /**
         * apply list grid column state
         */
        public void applyFieldState(){
            try{
                final String viewState = (String) Offline.get(getId());
                if (viewState != null) {
                    addDrawHandler(new DrawHandler() {  
    
                        @Override  
                        public void onDraw(DrawEvent event) {  
                            //restore any previously saved view state for this grid  
                            setViewState(viewState);  
                        }  
                    }); 
                }
             } catch(Exception e) {
    
             } 
            FieldStateChangedHandler fieldStateChangedHandler = new FieldStateChangedHandler() {
    
                @Override
                public void onFieldStateChanged(FieldStateChangedEvent event) {
                                Offline.put(getId(), getViewState());
                                updateFieldChangeCallBack();
                }
            };
            addFieldStateChangedHandler(fieldStateChangedHandler);
        }
    
        /*
         * The id of the offline storage
        */
        private String getId(){
            return LoginInfo.getLoginId()+"_"+getListGridId();
        }
    }
    Thanks in Advance
    Last edited by Isomorphic; 10 Oct 2014, 10:50.

    #2
    If we understand your question correctly, it sounds like when you load the new version of the application, this logic is running:

    Code:
                final String viewState = (String) Offline.get(getId());
                if (viewState != null) {
                    addDrawHandler(new DrawHandler() {  
    
                        @Override  
                        public void onDraw(DrawEvent event) {  
                            //restore any previously saved view state for this grid  
                            setViewState(viewState);  
                        }  
                    }); 
                }
    Meaning you pick up the stored viewState - but you want to avoid this.
    Probably the easiest fix for this would be to modify the logic to include version information when you store out the view state so you can choose whether or not to re-apply it. Possibly append a version stamp to the ID under which the preferences are being stored or similar.

    Let us know if we are misunderstanding your problem.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi,
      Thanks for your reply.
      As per my explanation, it tells the problem only specific to the List Grid state. But it is one of the scenarios of Browser cache issue( loading old version application code).
      Sorry for my insufficient information which I provided.

      What I mean to say is, When we deploy a new build of our Smart GWT application the user's browser doesn't always run the latest version of the code. The user has to clear their browser cache to get the updated app. Is there a way to force the browser to recognize the new version?

      Please suggest us, how to avoid this issue.


      Thanks in Advance.

      Comment


        #4
        This isn't a SmartClient issue, this is just web caching in general. There are many approaches, most of which just ensure that your application uses different URL for resources each time you deploy a new version. Please use web search to find many articles on the subject.

        Comment

        Working...
        X