Hello,
I currently evaluating the 3.1d enterprise edition (2012/10/04) and try to define my own SimpleType to handle a complex object like this:
I managed it, to extract the value via SimpleType::setSimpleTypeValueExtractor like this:
but the method SimpleType::setSimpleTypeValueUpdater seems not to work like I expect. Currently I've tried to to this:
The data send back to the server is equals to the one I received via the fetch operation. Am I missing something?
I currently evaluating the 3.1d enterprise edition (2012/10/04) and try to define my own SimpleType to handle a complex object like this:
Code:
prices:{
scales:[
{
amount:0,
[b]price:10,[/b]
}
],
}
Code:
setSimpleTypeValueExtractor(new SimpleTypeValueExtractor() {
@Override
public Object getAtomicValue(Object value) {
if (!(value instanceof Map)) return null;
List<Map> scales = (List) ((Map) value).get("scales");
if (scales == null){
return null;
}
for (Map scale : scales) {
if (((Number)scale.get("amount")).intValue() == 0){
return scale.get("price");
}
}
return null;
}
});
Code:
setSimpleTypeValueUpdater(new SimpleTypeValueUpdater() {
@Override
public Object updateAtomicValue(Object atomicValue, Object currentValue) {
if (!(currentValue instanceof Map)) return null;
List<Map> scales = (List) ((Map) currentValue).get("scales");
if (scales == null){
return currentValue;
}
for (Map scale : scales) {
if (((Number)scale.get("amount")).intValue() == 0){
scale.put("price", Float.valueOf(atomicValue.toString()));
}
}
return currentValue;
}
});
Comment