Date conversion error on saving form field that's read-only

We have a date field that’s read-only, as well as a converter for the EsfDate field we use to populate it. We are getting exceptions converting the “string display” date back to an EsfDate for this field, but we’re not sure why that’s even happening as a read-only field never is updated.

The “bean” we use has a ‘get’ method, but no ‘set’ method.

When we create the date field we use a TextField that is also marked a setReadOnly(true).

But when the form is updated (this date field cannot be modified), and they click Save, our form gets an exception that seems like is never needed (converting the string date in the TextField back to a our date format):

Caused by: java.lang.NullPointerException
at com.vaadin.ui.AbstractField.validate(
at com.vaadin.ui.AbstractField.validate(
at com.vaadin.ui.Form.validate(
at com.vaadin.ui.AbstractField.isValid(

We’d prefer to not fix trying to parse that display date held in the TextField as we don’t really know what date format will be used (it may not even be sufficient to reproduce the original date, say if their format just shows month and year, or just year, or just month/day, etc.). But why is the date string in the TextField trying to be converted anyway as the TextField is both read-only and tied to a bean that only has a get method (no set allowed)?

For lack of any response and therefore assuming there is no solution, we changed our bean so that the date field’s get method returns a string instead of the model’s date. But this converting from presentation to model on a field that is readonly and has no corresponding bean setter method is peculiar as the outcome of the conversion is never used.

You did not post the code for EsfDateConverter , but in general the converter must always handle the null values (both ways), and the null pointer seems to be generated in your converter.

The reason it converts it back to model value is to check if you tried to change the value, in the case where you change the value it will throw an exception stating that the propety is readonly.

The date isn’t null, it’s a valid string that can be in any of various date formats, making it impossible to easily re-parse it back to a date object. If the date field for 2015-10-27 is shown using a valid user-specified date display format like: “Tuesday, October 27, 2015” or just “October 27, 2015” or “27 October 2015” etc. these are not easily re-parsed back to the correct date.

As the field itself is read-only and has no bean setter method, the field should not need to be checked for a change. The UI should not allow that field to change even if the browser is hacked to send over a changed value.

I agree with you that the behaviour of readonly fields are quircky , was just stating why the converter was called.
You can try and cache the original value in the converter, and when it tries to convert from presentation to model value you simply return the cached value instead.
NOTE You will have to dedicate a converter instanace to each instance of the readonly field.