I am using a DateTimePickker with a bound LocalDate value and a corresponding Converter. The Converter is typed, i.e. implements Converter<LocalDate> not just Converter using Object. The field is also required.
When no value is set, on validation there is an error calling Converter<LocalDate> with the empty String "".
In the decode-Method Line 59 of the renderer subVal ist the empty String that is set as submitted value.
On rendering in the Method encodeHTML Line 222 the submitted value is retrieved as variable v, which is the empty String and not null. This value is passed to getValueAsString() and subsequently to getDateAsString()
In the call to getDateAsString in Line 115 the (untyped) converter is called with the empty String, which fails, because the expected parameter is of type LocalDate. This causes the converter to crash.
A workaround would be to implement untyped converters. But this is not the recommended way to implement converters.
One way to fix this would be to ensure that on setSubmittedValue no empty String is set but instead null.
I am using a
DateTimePickker
with a boundLocalDate
value and a corresponding Converter. The Converter is typed, i.e. implementsConverter<LocalDate>
not justConverter
usingObject
. The field is also required.When no value is set, on validation there is an error calling
Converter<LocalDate>
with the empty String "".In the decode-Method Line 59 of the renderer subVal ist the empty String that is set as submitted value.
On rendering in the Method encodeHTML Line 222 the submitted value is retrieved as variable
v
, which is the empty String and not null. This value is passed togetValueAsString()
and subsequently togetDateAsString()
In the call to
getDateAsString
in Line 115 the (untyped) converter is called with the empty String, which fails, because the expected parameter is of typeLocalDate
. This causes the converter to crash.A workaround would be to implement untyped converters. But this is not the recommended way to implement converters.
One way to fix this would be to ensure that on setSubmittedValue no empty String is set but instead
null
.Change the code in Line 59 and following of the renderer from
to
I am not sure if this can be done without any negative effects on other code, but it seems reasonable to me.