I updated the Vaadin libs in my app from 7.0.7 to 7.1.1 and now I’m getting an error during construction of a form if a field is set to read-only.
The relevant code looks like this:
FormLayout fl = new FormLayout();
FieldGroup fg = new FieldGroup();
TextField f = new TextField();
[...]
f.setReadOnly(true);
fgQuote.bind(f, "fieldname");
fl.addComponent(f);
This used to work in 7.0.
After updating to 7.1 the last line causes this exception:
[...]
Caused by: com.vaadin.data.Property$ReadOnlyException
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:465)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:445)
at com.vaadin.ui.AbstractTextField.setValue(AbstractTextField.java:432)
at com.vaadin.ui.AbstractTextField.setValue(AbstractTextField.java:35)
at com.vaadin.ui.AbstractField.setConvertedValue(AbstractField.java:823)
at com.vaadin.ui.AbstractField.localeMightHaveChanged(AbstractField.java:1400)
at com.vaadin.ui.AbstractField.attach(AbstractField.java:1358)
at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:478)
at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:215)
[...]
My work-around is to call f.setReadOnly(true) after fl.addComponent(f) - then it works again.
Question: Is this intended behaviour or maybe a bug?