imteam
2 Mar 2009, 12:44 PM
- GXT version: 1.2.3
- GWT 1.5.3
- Host mode
look at the code attached and look the output image ....
The test constructs a map (with a nested map) and try to encode / decode it.
The resulting map is not the same as the original map.
The test show:
ORIGINAL MAP:
{M1.K2={m2.k1=m2.val_1, m2.k2=m2.val_2}}
DECODED MAP:
{M1.K2={m2.k1=m2.val_1}, m2.k2=m2.val_2}
package it.dbj.gxt.client;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.extjs.gxt.ui.client.state.CookieProvider;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
public class Main implements EntryPoint {
public void onModuleLoad() {
RootPanel.get().add(newHTML());
}
private Widget newHTML() {
Map<String,Object> map = new HashMap<String, Object>();
Map<String,Object> map2 = new HashMap<String, Object>();
map2.put("m2.k1","m2.val_1");
map2.put("m2.k2","m2.val_2");
map.put("M1.K2", map2 );
TestProvider tp = new TestProvider();
String encodeMapString = tp.encodeMap(map);
Map<String,Object> decodedMap = tp.decodeMap(encodeMapString);
String html =
"ORIGINAL MAP:"+ "<BR/>" + map.toString() + "<BR/>" + "<BR/>" +
"DECODED MAP:" + "<BR/>" + decodedMap.toString();
return new HTML(html);
}
class TestProvider extends CookieProvider {
public TestProvider() {
this("/", null, null, false);
}
public TestProvider(String path, Date expires, String domain, boolean secure) {
super(path, expires, domain, secure);
}
@Override
public Map<String, Object> decodeMap(String value) {
return super.decodeMap(value);
}
@Override
public String encodeMap(Map<String, Object> map) {
return super.encodeMap(map);
}
}
}
I think the problem is the ecoding-separator ","
protected String com.extjs.gxt.ui.client.state.Provider.encodeMap(Map<String, Object> map) {
....
sb.append(key + "|" + val + ",");
....
}
protected Map<String, Object> decodeMap(String value) {
Map<String, Object> map = new HashMap<String, Object>();
String vals = value.substring(2);
String[] values = vals.split(",");
...
The last split () doesn't know about the fact that the map can contain other maps to be decode.
- GWT 1.5.3
- Host mode
look at the code attached and look the output image ....
The test constructs a map (with a nested map) and try to encode / decode it.
The resulting map is not the same as the original map.
The test show:
ORIGINAL MAP:
{M1.K2={m2.k1=m2.val_1, m2.k2=m2.val_2}}
DECODED MAP:
{M1.K2={m2.k1=m2.val_1}, m2.k2=m2.val_2}
package it.dbj.gxt.client;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.extjs.gxt.ui.client.state.CookieProvider;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
public class Main implements EntryPoint {
public void onModuleLoad() {
RootPanel.get().add(newHTML());
}
private Widget newHTML() {
Map<String,Object> map = new HashMap<String, Object>();
Map<String,Object> map2 = new HashMap<String, Object>();
map2.put("m2.k1","m2.val_1");
map2.put("m2.k2","m2.val_2");
map.put("M1.K2", map2 );
TestProvider tp = new TestProvider();
String encodeMapString = tp.encodeMap(map);
Map<String,Object> decodedMap = tp.decodeMap(encodeMapString);
String html =
"ORIGINAL MAP:"+ "<BR/>" + map.toString() + "<BR/>" + "<BR/>" +
"DECODED MAP:" + "<BR/>" + decodedMap.toString();
return new HTML(html);
}
class TestProvider extends CookieProvider {
public TestProvider() {
this("/", null, null, false);
}
public TestProvider(String path, Date expires, String domain, boolean secure) {
super(path, expires, domain, secure);
}
@Override
public Map<String, Object> decodeMap(String value) {
return super.decodeMap(value);
}
@Override
public String encodeMap(Map<String, Object> map) {
return super.encodeMap(map);
}
}
}
I think the problem is the ecoding-separator ","
protected String com.extjs.gxt.ui.client.state.Provider.encodeMap(Map<String, Object> map) {
....
sb.append(key + "|" + val + ",");
....
}
protected Map<String, Object> decodeMap(String value) {
Map<String, Object> map = new HashMap<String, Object>();
String vals = value.substring(2);
String[] values = vals.split(",");
...
The last split () doesn't know about the fact that the map can contain other maps to be decode.