DataSourceField.getValueMap() accepts when the ds.xml file specifies it as only a list of legal values
i.e. When the ds.xml file looks like:
<DataSource>
<field name="dummy" >
<valueMap>
<value>one</value>
<value>two</value>
</valueMap>
</field>
<DataSource/>
It is not obvious how to get at the values from the DataSourceField API or how to know when they are specified as a list of values as opposed to values mapped to user-visible values. DataSource.getDataSource(dataSourceName).getField("dummy").getValueMap() accepts for the above case. It works as expected when the value is definition is similar to <value ID="1">Pens>
What is the right way to determine if a DataSourceFiled has a value map, and then get to the values? This needs to work whether it was specified as a list of values or a map to user-visible values.
This just seems like an awful hack:
if (DataSource.getDatasource(dataSouceName.getField("dummy").getAttribute("valuMap"){ // our field has an enum like mapping
JavaScriptObject object = DataSource.getDataSource(dataSourceName).getField("dummy").getAttributeAsJavaScriptObject("valueMap");
String txt += JSOHelper.convertToJava(object).getClass().getName();
if (txt.contains("List"){
// do list processing
}else if (txt.contains("Map")){
// do map processing
}
}
If you consider this a bug, for compatibility sake, one might expect to get back a map from dummy's getValueMap() call that looked like {"one":"one", "two":"two"} .
SmartClient Version: SNAPSHOT_v11.1d_2017-05-21/PowerEdition Deployment (built 2017-05-21)