I’m trying to use a ValuesManager to control multiple forms (with different datasource on them) at the same time. When i add a form to the values manager instance i get the following error:
06:26:35.836 [ERROR] Failed to create an instance of 'net.keydriving.backoffice.gui.crm.client.form.basic.CompanyForm' via deferred binding
com.google.gwt.core.client.JavaScriptException: (TypeError): this.getDataSource() is undefined fileName: http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Forms.js lineNumber: 2633 stack: ([object Object])@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Forms.js:2633 ([object GWTJavaObject])@http://localhost:8080:40 @:0 ([object GWTJavaObject],131229,[object GWTJavaObject])@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/hosted.html?crm:56 ([object Object],0,0)@http://localhost:8080:2398 anonymous([object Object],0,0)@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Grids.js:828 ([object Object],0,0)@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Grids.js:696 (0,0)@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Grids.js:693 ([object Object],(void 0))@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Grids.js:690 ([object Object],(void 0))@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:2924 ([object Object],"click")@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:1453 ([object Object])@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:1314 ([object MouseEvent],(void 0))@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:1301 ([object MouseEvent])@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:1292 ((function (_1, _2) {var _3 = isc.EH;if (isc.Browser.isIE && !_3.$j6) {var _4 = _3.lastEvent;_4.eventType = _3.MOUSE_DOWN;_3.handleMouseDown(null, _3.lastEvent);}if (!_2) {_3.$ku = true;}var _5 = _3.$k5(_1, _2);_3.$ku = false;if (isc.Browser.isSafari) {_5 = true;}return _5;}),[object MouseEvent])@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:1513 anonymous([object MouseEvent])@http://localhost:8080/net-keydriving-backoffice-gui-crm-0.0.1-SNAPSHOT/crm/sc/modules/ISC_Core.js:60
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.addMember(ValuesManager.java)
at net.keydriving.backoffice.gui.crm.client.form.basic.AbstractBasicForm.createFormLayout(AbstractBasicForm.java:346)
It seems that you have to assign a datasource to the values manager to get it working, the documentation does not specify this but suggest this is optional? I added a Datasource to work around the issue, but only a little further i’m stuck once again.
I have a VStack which creates a DynamicForm and adds it to itself as a member and to the ValuesManager. Some other forms are also generated in code and all of them are added to the same ValuesManager. But when trying to access the forms on the ValuesManager via the getMembers method i’m greeted with a ClassCastException.
Code which generates the first form added:
protected void createFormLayout(final FormType formType, final Boolean useAllDataSourceFields) {
GWT.log("Creating the underling dynamicform.", null);
_form = new DynamicForm();
_form.setAutoFocus(Boolean.TRUE);
_form.setUseAllDataSourceFields(useAllDataSourceFields);
// General layout stuff
_form.setWidth100();
_form.setNumCols(2);
_form.setColWidths("50%", "50%");
_form.setTitleOrientation(TitleOrientation.TOP); // Labels above the boxes
// Set the datasource for the form, and add the form to the values manager
_form.setDataSource(DataSource.get(formType.getDataSourceId()));
getValuesManager().addMember(_form);
GWT.log("Creating the header for the form.", null);
_header = new FormHeader(this);
addRecordChangedHandler(_header);
addMember(_header);
addMember(_form);
}
The form gets added here to the values manager, but when a retrieval is done, like for example:
public void enable() {
GWT.log("Enabling forms via valuesManager: " + getValuesManager());
for (final DynamicForm form : getValuesManager().getMembers()) {
GWT.log("Enabling form: " + form);
form.enable();
}
}
A ClassCastException is thrown:
06:49:57.636 [ERROR] Uncaught exception escaped
java.lang.ClassCastException: net.keydriving.backoffice.gui.crm.client.form.basic.CompanyForm cannot be cast to com.smartgwt.client.widgets.form.DynamicForm
at com.smartgwt.client.widgets.form.DynamicForm.getOrCreateRef(DynamicForm.java:87)
at com.smartgwt.client.widgets.form.ValuesManager.convertToDynamicFormArray(ValuesManager.java:649)
at com.smartgwt.client.widgets.form.ValuesManager.getMembers(ValuesManager.java:638)
at net.keydriving.backoffice.gui.crm.client.form.basic.AbstractBasicForm.enable(AbstractBasicForm.java:326)
at net.keydriving.backoffice.gui.crm.client.form.AbstractForm$1.onSuccess(AbstractForm.java:62)
at net.keydriving.backoffice.gui.crm.client.form.AbstractForm$1.onSuccess(AbstractForm.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:393) 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.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.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:637)
I tried assigning a ID to the form, but each time the Class which nested the created form is returned as a member of the valuesManager? Why am i getting the class encapsulating the DynamicForm added instead of the DynamicForm itself which was added?
Thanks in advance
