I'm trying to get access to a component within a grid, so that I can invoke methods on it. Instead I'm getting a javascript error, "(TypeError): Unable to get value of the property '$669': object is null or undefined"
1. SmartClient Version: SNAPSHOT_v8.3d_2012-10-09/Enterprise Deployment (built 2012-10-09)
2. IE 9
3. N/A
4. N/A
5. stack trace:
6. sample code:
module:
grid:
component:
1. SmartClient Version: SNAPSHOT_v8.3d_2012-10-09/Enterprise Deployment (built 2012-10-09)
2. IE 9
3. N/A
4. N/A
5. stack trace:
Code:
ERROR: Uncaught exception escaped com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129) 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.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) 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:213) at sun.reflect.GeneratedMethodAccessor37.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:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) at java.lang.Thread.run(Thread.java:662) Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): Unable to get value of the property '$669': object is null or undefined at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.smartgwt.client.widgets.grid.ListGrid.getRecordComponent(ListGrid.java) at com.hyperproductive.play.client.PlayPoint$2.onClick(PlayPoint.java:54) at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:101) at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1) at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1) at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40) at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193) at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88) at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127) 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.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) 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:213) at sun.reflect.GeneratedMethodAccessor37.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:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) at java.lang.Thread.run(Thread.java:662)
module:
Code:
@Override public void onModuleLoad() { final DataSource formDataSource = new DataSource(); formDataSource.setClientOnly(true); DataSourceTextField textField = new DataSourceTextField("text", "Text", 5000); DataSourceTextField selectionField = new DataSourceTextField("select", "Select Something"); formDataSource.setFields(textField, selectionField); final Record record1 = new Record(); record1.setAttribute("text", "This is the initial text."); record1.setAttribute("select", "V2"); final Record record2 = new Record(); record2.setAttribute("text", "This text in the second record"); record2.setAttribute("select", "V3"); final SampleListGrid grid = new SampleListGrid(); grid.setDataSource(formDataSource); grid.setData(new Record[] {record1, record2}); final IButton debug = new IButton("debug"); debug.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.showConsole(); } }); final IButton hello = new IButton("hello"); hello.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // ERROR OCCURS HERE final Canvas component = grid.getRecordComponent(1); if (component != null) { ((SampleComponent) component).sayHello(); } } }); final VLayout layout = new VLayout(); layout.setMembers(debug,hello, grid); layout.draw(); }
Code:
package com.hyperproductive.play.client; import com.smartgwt.client.types.EmbeddedPosition; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridRecord; /** * Create a simple list grid to demonstrate component functionality */ public class SampleListGrid extends ListGrid { public SampleListGrid() { setBackgroundColor("white"); setHeight100(); setWidth100(); setCanEdit(true); setCanReorderRecords(true); setCanAcceptDroppedRecords(true); setShowRecordComponents(true); setShowRecordComponentsByCell(false); setRecordComponentPosition(EmbeddedPosition.WITHIN); setAutoFetchData(false); } @Override protected Canvas createRecordComponent(ListGridRecord record, Integer colNum) { return new SampleComponent(record); } }
Code:
package com.hyperproductive.play.client; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.HLayout; /** * use as a component within the ListGrid */ public class SampleComponent extends HLayout { static DataSource componentDataSource; private ListGridRecord displayedRecord; static { componentDataSource = new DataSource(); componentDataSource.setClientOnly(true); DataSourceTextField textField = new DataSourceTextField("text", "Text", 5000); DataSourceTextField selectionField = new DataSourceTextField("select", "Select Something"); componentDataSource.setFields(textField, selectionField); } public SampleComponent(final ListGridRecord record) { super(); this.setWidth100(); this.displayedRecord = record; final DynamicForm componentForm = new DynamicForm(); componentForm.setDataSource(componentDataSource); componentForm.editRecord(record); this.addMember(componentForm); } public void sayHello() { final String text = this.displayedRecord.getAttribute("text"); SC.say("Text: " + text); } }
Comment