help!!!!
I m writed a simple code
for example :
public void onModuleLoad() {
DataSource dataSource=new DataSource();
DataSourceIntegerField a1=new DataSourceIntegerField("id","id");
a1.setPrimaryKey(true);
DataSourceTextField a2=new DataSourceTextField("name","name");
DataSourceIntegerField a3=new DataSourceIntegerField("age","age");
dataSource.setFields(a1,a2,a3);
dataSource.setClientOnly(true);
dataSource.setDataFormat(DSDataFormat.XML);
dataSource.setRecordXPath("/list/record");
dataSource.setDataURL("/aa.xml");
final ListGrid ll=new ListGrid();
ll.setDataSource(dataSource);
ll.setAutoFetchData(true);
ll.draw();
ll.addRecordClickHandler(new RecordClickHandler(){
public void onRecordClick(RecordClickEvent event) {
Record temp=ll.getSelectedRecord();
System.out.println(new JSONObject(temp.getJsObj()));
Record temp2=new Record();
temp2.setAttribute("id", 4);
temp2.setAttribute("name", "testtest4");
temp2.setAttribute("age", 66);
System.out.println(new JSONObject(temp2.getJsObj()));
}
});
}
why
System.out.println(new JSONObject(temp.getJsObj())); SUCCESS?
why
System.out.println(new JSONObject(temp2.getJsObj())); Throw Exception??
I want new a Record and set some Attribute param after convert the JSON.
the console print:
{"id":2, "name":"testtest2", "age":12, "_selection_1":true}
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:122)
at com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:57)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:68)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:153)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:453)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:231)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.json.client.JSONParser.createObject(JSONParser.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.MethodDispatch.invoke(MethodDispatch.java:97)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:68)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:153)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:453)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:231)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.json.client.JSONObject.get0(JSONObject.java)
at com.google.gwt.json.client.JSONObject.get(JSONObject.java:89)
at com.google.gwt.json.client.JSONObject.toString(JSONObject.java:183)
at java.lang.String.valueOf(String.java:2827)
at java.io.PrintStream.println(PrintStream.java:771)
at com.mycompany.project.client.ImageViewer$1.onRecordClick(ImageViewer.java:44)
at com.smartgwt.client.widgets.grid.events.RecordClickEvent.dispatch(RecordClickEvent.java:96)
at com.smartgwt.client.widgets.grid.events.RecordClickEvent.dispatch(RecordClickEvent.java:1)
at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:264)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:557)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
I m writed a simple code
for example :
public void onModuleLoad() {
DataSource dataSource=new DataSource();
DataSourceIntegerField a1=new DataSourceIntegerField("id","id");
a1.setPrimaryKey(true);
DataSourceTextField a2=new DataSourceTextField("name","name");
DataSourceIntegerField a3=new DataSourceIntegerField("age","age");
dataSource.setFields(a1,a2,a3);
dataSource.setClientOnly(true);
dataSource.setDataFormat(DSDataFormat.XML);
dataSource.setRecordXPath("/list/record");
dataSource.setDataURL("/aa.xml");
final ListGrid ll=new ListGrid();
ll.setDataSource(dataSource);
ll.setAutoFetchData(true);
ll.draw();
ll.addRecordClickHandler(new RecordClickHandler(){
public void onRecordClick(RecordClickEvent event) {
Record temp=ll.getSelectedRecord();
System.out.println(new JSONObject(temp.getJsObj()));
Record temp2=new Record();
temp2.setAttribute("id", 4);
temp2.setAttribute("name", "testtest4");
temp2.setAttribute("age", 66);
System.out.println(new JSONObject(temp2.getJsObj()));
}
});
}
why
System.out.println(new JSONObject(temp.getJsObj())); SUCCESS?
why
System.out.println(new JSONObject(temp2.getJsObj())); Throw Exception??
I want new a Record and set some Attribute param after convert the JSON.
the console print:
{"id":2, "name":"testtest2", "age":12, "_selection_1":true}
java.lang.ClassCastException
at java.lang.Class.cast(Class.java:2990)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:122)
at com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:57)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:68)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:153)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:453)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:231)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.json.client.JSONParser.createObject(JSONParser.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.MethodDispatch.invoke(MethodDispatch.java:97)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:68)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:153)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:453)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:231)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.json.client.JSONObject.get0(JSONObject.java)
at com.google.gwt.json.client.JSONObject.get(JSONObject.java:89)
at com.google.gwt.json.client.JSONObject.toString(JSONObject.java:183)
at java.lang.String.valueOf(String.java:2827)
at java.io.PrintStream.println(PrintStream.java:771)
at com.mycompany.project.client.ImageViewer$1.onRecordClick(ImageViewer.java:44)
at com.smartgwt.client.widgets.grid.events.RecordClickEvent.dispatch(RecordClickEvent.java:96)
at com.smartgwt.client.widgets.grid.events.RecordClickEvent.dispatch(RecordClickEvent.java:1)
at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:264)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:557)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
Comment