Java 在使用SmartGwt ListGrid脱机存储时,如何避免在切换web应用程序版本之间出现缓存问题?
我对smart GWT是新手。在listGrid唯一id的帮助下,我将listGrid的状态存储在脱机存储中。我正在使用包Java 在使用SmartGwt ListGrid脱机存储时,如何避免在切换web应用程序版本之间出现缓存问题?,java,smartgwt,Java,Smartgwt,我对smart GWT是新手。在listGrid唯一id的帮助下,我将listGrid的状态存储在脱机存储中。我正在使用包com.smartgwt.client.util.Offline来存储listGrid的状态。现在,在我的软件的version1中存储了listGrid的状态之后,当我上传一个新版本,即version2时,listGrid的状态没有改变。虽然我上传了一个新的版本2和新编译的智能GWT模块,但它使用的是版本1的状态。但是,当我清除浏览器缓存时,我能够获得ListGrid的新状态
com.smartgwt.client.util.Offline
来存储listGrid的状态。现在,在我的软件的version1
中存储了listGrid的状态之后,当我上传一个新版本,即version2
时,listGrid的状态没有改变。虽然我上传了一个新的版本2和新编译的智能GWT模块,但它使用的是版本1的状态。但是,当我清除浏览器缓存时,我能够获得ListGrid的新状态。我的问题是:
当我上传一个新版本时,有没有办法在不清除浏览器缓存的情况下获取ListGrid的新状态
请检查下面的示例代码表
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();
}
}
如有任何建议,将不胜感激