I'm trying to define the subset of operators allowed for a datasource field using the datasource XML definition, but I'm not having any luck.
I updated the "itemName" field definition in the sample supplyItem.ds.xml a couple of ways:
1) using the syntax found elsewhere in the forums
This generates the following output:
2) trying to create a "richer" element structure
This generates the following output:
Here is the code used to test this:
SmartGWT version: SC_SNAPSHOT-2012-01-19_v8.2p/PowerEdition Deployment 2012-01-19
Browser: IE 9
Running in hosted mode.
Thanks for any insight into the validOperators feature.
I updated the "itemName" field definition in the sample supplyItem.ds.xml a couple of ways:
1) using the syntax found elsewhere in the forums
Code:
<field name="itemName" type="text" title="Item" length="128" required="true"> <validOperators>contains</validOperators> </field>
Code:
INFO: field: itemID. INFO: field: itemName. ERROR: Unable to load module entry point class com.mySampleApplication.client.MySampleApplication (see associated exception for details). java.lang.ClassCastException: java.lang.String cannot be cast to com.google.gwt.core.client.JavaScriptObject at com.smartgwt.client.util.JSOHelper.getAttributeAsJavaScriptObject(JSOHelper.java) at com.smartgwt.client.util.JSOHelper.getAttributeAsStringArray(JSOHelper.java:317) at com.smartgwt.client.core.DataClass.getAttributeAsStringArray(DataClass.java:124) at com.smartgwt.client.data.DataSourceField.getValidOperators(DataSourceField.java:1232) at com.mySampleApplication.client.MySampleApplication.onModuleLoad(MySampleApplication.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) at java.lang.Thread.run(Thread.java:722)
Code:
<field name="itemName" type="text" title="Item" length="128" required="true"> <validOperators> <operatorId>contains</operatorId> </validOperators> </field>
Code:
INFO: field: itemID. INFO: field: itemName. ERROR: Unable to load module entry point class com.mySampleApplication.client.MySampleApplication (see associated exception for details). java.lang.ClassCastException: [Lcom.smartgwt.client.types.ValueEnum; cannot be cast to [Lcom.smartgwt.client.types.OperatorId; at com.smartgwt.client.data.DataSourceField.getValidOperators(DataSourceField.java:1232) at com.mySampleApplication.client.MySampleApplication.onModuleLoad(MySampleApplication.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) at java.lang.Thread.run(Thread.java:722)
Code:
public void onModuleLoad() { final DataSource dataSource = DataSource.get("supplyItem"); DataSourceField[] fields = dataSource.getFields(); for (DataSourceField field : fields) { String fieldName = field.getName(); GWT.log("field: " + fieldName); OperatorId[] validOperators = field.getValidOperators(); // ERROR! if (validOperators != null) { for (OperatorId validOperator : validOperators) { GWT.log("operatorId: " + validOperator.getValue()); } } } final FilterBuilder filter = new FilterBuilder(); filter.setDataSource(dataSource); final VStack layout = new VStack(); layout.addMember(filter); layout.draw(); }
Browser: IE 9
Running in hosted mode.
Thanks for any insight into the validOperators feature.
Comment