Hi,
Evaluating smart gwt EE (latest nightly build) and using Internet Explorer...
The relevant field from my descriptor xml is the following:
Could it be that because field is set to MULTIPLE and I link this to a custom java class that it doesn't work? (In the DTO I return an ArrayList<SofLinkDTO>).
When multiple set to "false" and returning a single SofLinkDTO it works fine.
When I change from multiple "false" to "true" (and ofcourse change the return type of my DTO from SofLinkDTO to an ArrayList<SofLinkDTO> I don't get a javascript object anymore! But it reverts to a String [Object object].
I tried casting to JavaScriptObject, Record, Map, LinkedHashMap, ArrayList, String[], etc. etc.
It just seems that SmartGWT can't handle the field set to multiple and a custom object returned in an ArrayList.
As you can see I have implemented my own simple type:
Please don't answer with OptionalDataSource... not relevant for this case ;-)
Thanks a lot!
Evaluating smart gwt EE (latest nightly build) and using Internet Explorer...
The relevant field from my descriptor xml is the following:
Code:
<field name="theCountryLinks" title="theCountryLinks" multiple="true" type="silkCountryLink" javaClass="outpost.dto.SofLinkDTO" />
When multiple set to "false" and returning a single SofLinkDTO it works fine.
When I change from multiple "false" to "true" (and ofcourse change the return type of my DTO from SofLinkDTO to an ArrayList<SofLinkDTO> I don't get a javascript object anymore! But it reverts to a String [Object object].
I tried casting to JavaScriptObject, Record, Map, LinkedHashMap, ArrayList, String[], etc. etc.
It just seems that SmartGWT can't handle the field set to multiple and a custom object returned in an ArrayList.
As you can see I have implemented my own simple type:
Code:
public class SilkCountryLink extends SimpleType { public final static String SIMPLETYPE_NAME = "silkCountryLink"; public SilkCountryLink() { super(SIMPLETYPE_NAME, FieldType.ENUM); //get value map from a custom client cache super.setValueMap(SilkClientCache.getAllCountries()); this.setNormalDisplayFormatter(new Formatter()); this.setShortDisplayFormatter(new Formatter()); } private class Formatter implements SimpleTypeFormatter { public String format(Object value, DataClass field, DataBoundComponent component, Record record) { if(value == null){ return ""; } //THIS ONLY WORKS IN CASE MULTIPLE=false if(value instanceof JavaScriptObject){ JavaScriptObject object = (JavaScriptObject) value; Integer id = JSOHelper.getAttributeAsInt(object, "id"); if(id != Integer.MIN_VALUE){ LinkedHashMap<String, String> values = LinkedHashMap<String, String>) JSOHelper.getAttributeAsMap(field.getJsObj(), "valueMap"); return values.get (String.valueOf(id)); } return ""; } return (String) value; } }
Thanks a lot!
Comment