I am working on date fields and have problems with the validation. I
have referred to the link below which helped me.


So I have subclassed the PatternDateConverter and have set the pattern
dateFormat = "^(\\d{1,2})/(\\d{1,2})/(\\d{4})$";

I have 2 date fields, start_date and end_date. The start_date is a
required field and the end_date is not.

.... some code

pdc = new

.... more code

startDateField = DateTextField.withConverter("startDate", new
PropertyModel(this, "startDate"), pdc);
startDateField.add(new TMPDatePicker());
endDateField = DateTextField.withConverter("endDate", new
PropertyModel(this, "endDate"), pdc);
endDateField.add(new TMPDatePicker());

.... more code

This works fine ie it does not allow entry of "03/03/09" or

BUT, the end_date becomes a required field. I have to enter the end_date
to click 'Save'. Else it complains that an invalid date has been
But my end_date is not a required field.

So if I replace it with,

endDateField = DateTextField.forDatePattern("endDate",
endDateField.withConverter("endDate", pdc);
endDateField.add(new TMPDatePicker());

It allows, "03/03/-2009" and "03/03/09". Why does it allow the '-' sign.
It computes it to a value and displays a year.

My application has several date fields and I need to validate them.

I am a newbie to Wicket and have looked up the archive quite a bit to
find a solution.
Can someone please tell me a solution to my date validation problem?

Thanks very much

Reply via email to