Java GWT国际象棋+;MVP并尝试在本地存储中存储状态
我到现在为止一直在做这件事Java GWT国际象棋+;MVP并尝试在本地存储中存储状态,java,gwt,local-storage,mvp,chess,Java,Gwt,Local Storage,Mvp,Chess,我到现在为止一直在做这件事 public void addStorage() { stockStore = Storage.getLocalStorageIfSupported(); if (stockStore != null) { stockStore.setItem(("Index" + index), ("state" + HistoryCount)); stockMap.put(("Index" + index), ("state" +
public void addStorage() {
stockStore = Storage.getLocalStorageIfSupported();
if (stockStore != null) {
stockStore.setItem(("Index" + index), ("state" + HistoryCount));
stockMap.put(("Index" + index), ("state" + HistoryCount));
}
}
public void loadStorage() {
String s;
stockStore = Storage.getLocalStorageIfSupported();
if (stockStore != null) {
stockMap = new
StorageMap(stockStore);
for (int i = 0; i < stockStore.getLength(); i++) {
if (stockMap.containsValue(index)) {
s = stockStore.getItem("Index" + index);
state = stateRecord.get(s);
clearHighlights();
setState(state);
break;
}
}
}
}
public void addStorage(){
stockStore=Storage.getLocalStorageIfSupported();
if(stockStore!=null){
stockStore.setItem((“索引”+索引),(“状态”+历史计数));
股票价格((“指数”+指数),(“状态”+历史计数));
}
}
公共存储空间(){
字符串s;
stockStore=Storage.getLocalStorageIfSupported();
if(stockStore!=null){
stockMap=新
StorageMap(stockStore);
对于(int i=0;i
我不知道我错过了什么。这两个函数由它们的处理程序调用。加载并保存。加载存储将加载已存储的国际象棋状态,保存将保存当前的国际象棋状态。可能您在
stockMap中有错误。containsValue(index)
但应为stockMap.containsValue(“index”+index)
,更正版本:
for (int i = 0; i < stockStore.getLength(); i++) {
if (stockMap.containsValue("Index" + index)) {
s = stockStore.getItem("Index" + index);
state = stateRecord.get(s);
clearHighlights();
setState(state);
break;
}
}
for(int i=0;i
问题是什么???这不起作用。我的状态仍然没有被保存或加载。代码有问题吗?