How to make PopupDateField use Converters for default date formats

Hi all,

I’m using a PopupDateField with:

  • obj.setLocale(…);
  • obj.setDateFormat(…);
  • protected Date handleUnparsableDateString(String dateString) …

The problem is: I need every string I enter to be parsed by handleUnparsableDateString().
Instead, I get that only strings which cannot be directly parsed by the client are handled by that method; which is probably the intended behaviour, but not suitable for my needs :slight_smile:

Is there any way to bypass the standard parsing algorithm and always use handleUnparsableDateString() instead?

Thanks a lot for your help,
Marco

Well, actually the title of the post should be renamed to “Disabling client-side validation in DateField”.

I see no way to do that by overriding something via server-side…

Thanks,
Marco

I opened a ticket (
http://dev.vaadin.com/ticket/15537
) to ask for a specific method to disable client-side validation.

In the meanwhile, as explained in the very same ticket, I found a way to force MyPopupDateField to always use handleUnparsableDateString, i.e.: to always rely on server-side validation. This was done by overriding some variables in changeVariables() in order to force DateField not to recognize the date as valid and to always call handleUnparsableDateString().

Just in case anyone else encounters the same problem…

Thanks,
Marco

Thank you for the ticket. I agree there should be a way to do this; for instance, on the server side one could simply use
SimpleDateFormat.set2DigitYearStart(Date startDate)
to do what you’re after. Unfortunately SimpleDateFormat is not implemented in GWT and we instead use GWT’s own tools for the clientside validation.

Hi Johannes, and thanks for your reply.

Yes, I agree that SimpleDateFormat.set2DigitYearStart() could do the trick on the server-side, but I have my own classes to deal with multiple input format and they work with no problems on the server.
The problem, as you said, is on GWT. So for now I’m stuck with my “dirty” solution in changeVariables(), which is: setting wrong values on the date fields to force the code to jump to handleUnparsableString().

Thanks a lot,
Marco