Hello everybody,
I'm migrating from GWT 1.6 and SmartGWT 1.2 to GWT 2.03 and SmartGWT 2.2.
The start of the migration was fine, but now I found a problem.
I always set a custom pojo-object to the Record (setAttribute(String, Object)), so I have access to it. This worked fine before the migration. But now I'm getting a JavaScriptException, when I try to use such a Record with the editRecord(Record) method of the ValuesManager.
I use:
GWT 2.03
SmartGWT 2.2
Firefox 3.5.9
Ubuntu 9.10
Here is a minimal example, that throws an exception, when you click on the second record with the Object as attribute:
The execption, that is thrown:
Is this a bug or am I doing something wrong?
I'm migrating from GWT 1.6 and SmartGWT 1.2 to GWT 2.03 and SmartGWT 2.2.
The start of the migration was fine, but now I found a problem.
I always set a custom pojo-object to the Record (setAttribute(String, Object)), so I have access to it. This worked fine before the migration. But now I'm getting a JavaScriptException, when I try to use such a Record with the editRecord(Record) method of the ValuesManager.
I use:
GWT 2.03
SmartGWT 2.2
Firefox 3.5.9
Ubuntu 9.10
Here is a minimal example, that throws an exception, when you click on the second record with the Object as attribute:
Code:
package example; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DSResponse; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.DSProtocol; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.ValuesManager; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; import com.smartgwt.client.widgets.grid.events.SelectionEvent; import com.smartgwt.client.widgets.layout.VLayout; public class EntryPoint implements EntryPoint{ public void onModuleLoad() { // create the ui elements VLayout layout = new VLayout(); DataSource ds = new GwtRpcDataSource(); final DynamicForm form = new DynamicForm(); TextItem textItem = new TextItem("title"); form.setFields(textItem); final ValuesManager vm = new ValuesManager(); vm.setDataSource(ds); vm.addMember(form); final ListGrid grid = new ListGrid(); grid.setWidth(200); grid.setHeight(200); grid.setDataSource(ds); layout.addMember(form); layout.addMember(grid); // add it RootPanel.get().clear(); RootPanel.get().add(layout); // fetch the data from the data source grid.fetchData(); // add a handler for getting the exception grid.addSelectionChangedHandler(new SelectionChangedHandler() { @Override public void onSelectionChanged(SelectionEvent event) { if (event.getState()) // editRecord throws an exception if the record has an object as attribute vm.editRecord(event.getSelectedRecord()); } }); } private class GwtRpcDataSource extends DataSource { public GwtRpcDataSource() { setDataProtocol(DSProtocol.CLIENTCUSTOM); setDataFormat(DSDataFormat.CUSTOM); setClientOnly(false); DataSourceTextField idField = new DataSourceTextField("id"); idField.setRequired(true); idField.setPrimaryKey(true); addField(idField); DataSourceTextField titleField = new DataSourceTextField("title"); titleField.setRequired(true); addField(titleField); } @Override protected Object transformRequest(DSRequest request) { String requestId = request.getRequestId(); DSResponse response = new DSResponse(); response.setAttribute("clientContext", request.getAttributeAsObject("clientContext")); response.setStatus(0); switch (request.getOperationType()) { case FETCH: executeFetch(requestId, request, response); break; default: break; } return request.getData(); } protected void executeFetch(final String requestId, final DSRequest request, final DSResponse response) { // one record without an object Record r1 = new ListGridRecord(); r1.setAttribute("id", "1"); r1.setAttribute("title", "Record 1"); // the second with an object as attribute Record r2 = new ListGridRecord(); r2.setAttribute("id", "2"); r2.setAttribute("title", "Record 2: not working"); r2.setAttribute("userObject", new Object()); Record[] list = new ListGridRecord[2]; list[0] = r1; list[1] = r2; response.setData(list); processResponse(requestId, response); } } }
Code:
com.google.gwt.core.client.JavaScriptException: (null): null at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.smartgwt.client.widgets.form.ValuesManager.editRecord(ValuesManager.java) at example.EntryPoint$1.onSelectionChanged(TaggingEntryPoint.java:58) at com.smartgwt.client.widgets.grid.events.SelectionEvent.dispatch(SelectionEvent.java:95) at com.smartgwt.client.widgets.grid.events.SelectionEvent.dispatch(SelectionEvent.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:67) 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.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188) at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source) 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.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157) at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619)
Comment