I have 2 editable fields (doubles) and a 3th read-only field that is the sum of the 2 other fields:
This work well to edit the form, but when I try to save such a form I get the follow exception:Code:getFormModel().getFieldMetadata("c").setReadOnly(true); //... formBuilder.add("a"); formBuilder.row(); formBuilder.add("b"); formBuilder.row(); formBuilder.add("c"); formBuilder.row(); private class FinancingValueChangeMonitor extends AbstractValueChangeMonitor { //... public void onValueChange(Object oldValue, Object newValue) { Double a= (Double) getValueModel("a").getValue(); Double b= (Double) getValueModel("b").getValue(); Double c= a + b; getValueModel("c").setValue(c); } }
org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'c' of bean class [x.X]
X has a getter for a, b, c and a setter for a, b.
Because c is calculated on a and b, it doesn't have a setter for that, which causes the array.
How I can prevent form to setC on my X when a commit of the form occurs?


Reply With Quote