Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

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

$
0
0
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

Viewing all articles
Browse latest Browse all 4756

Trending Articles