Vaadin 7.4.2 error on FieldGroup Bind Readonly Field

Today, I try to upgrate my code from Vaadin 7.3.8 to Vaadin 7.4.2, but getting FieldGroup Binding Exception:
com.vaadin.data.Property$ReadOnlyException
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:471)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:451)
at com.vaadin.ui.AbstractTextField.setValue(AbstractTextField.java:455)
at com.vaadin.ui.TextField.clear(TextField.java:146)
at com.vaadin.data.fieldgroup.FieldGroup.bind(FieldGroup.java:261)

Trace to to code:
if (itemDataSource == null) {
// Clear any possible existing binding to clear the field
field.setPropertyDataSource(null);
field.clear();
// Will be bound when data source is set
return;
}

So if field already been set to readonly, will getting above error.
Same code runs without error on 7.3.8.

Does fieldgroup code need to add some condition check when binded field is readonly?

Thanks

Read only is… read only, you can’t change its value… And when you bind it - you change its value.
If you need to edit such field, you can just use:
field.setReadOnly(false);
field.setPropertyDataSource(null);
field.clear();
field.setReadOnly(true);
Is there any problem with this?

Wei Feng Gao:

I am facing the same problem in versioni 7.4.2, but things are working fine in 7.3.6 version.
What I have found out is inside FieldGroup bind method

field.setPropertyDataSource(null);

when above specified code get executed it goes to AbstractFiled setPropertyDataSource(), and as per the implemention of this method it call getInternalValue() which we generally override to get the values from BeanItemContainer which is NULL till this point… so it leads to NULL pointer Exception.

field.setPropertyDataSource(null);
is not there in 7.3.6 version.

Please let me know if you found any solution for this.

Wei Feng Gao:

I am facing the same problem in versioni 7.4.2, but things are working fine in 7.3.6 version.
What I have found out is inside FieldGroup bind method
field.setPropertyDataSource(null);
when above specified code get executed it goes to AbstractFiled setPropertyDataSource(), and as per the implemention of this method it call getInternalValue() which we generally override to get the values from BeanItemContainer which is NULL till this point… so it leads to NULL pointer Exception.
field.setPropertyDataSource(null); is not there in 7.3.6 version.

Please let me know if you found any solution for this.

Hi,

This seems to be issue https://dev.vaadin.com/ticket/17166, for which there is now a fix in review: https://dev.vaadin.com/review/#/c/8820

I created a few other tickets related to this also about things I noted while fixing the problem:
https://dev.vaadin.com/ticket/17847
https://dev.vaadin.com/ticket/17849
https://dev.vaadin.com/ticket/17850

The most major one I think is that FieldGroup should not always overwrite the enabled/readOnly state of fields but allow the state to be configured by the user

Artur,

Is there a planned date to release the fix for this? We use the setting to null in many places and this creates errors all the time since we upgraded from 7.3 to 7.4.

Our code generally looks like this:
fieldGroup.setItemDataSource(null);

We also have some old Form subclassing in which the code is:
super.setItemDataSource(null);

Hi,

Looks like it will be in 7.4.8. It is currently stuck in review until I get some test issues sorted out