I have created a JSP which has input field for date which accepts date like 1987-12-16
<dsp:input bean="RegisterFormHandler.dob" date="yyyy-MM-dd" size="25" type="text" required="true" />
and I am trying to set the value in RepositoryFormHandler
public void setDob(SimpleDateFormat dob)
{
this.dob = dob;
}
but set property is not calling the above function, I am not sure what is the problem here.
Your problem is that you are trying to call
setDob(SimpleDateFormat dob)
where what you meant wassetDob(Date dob)
. You are not passing the format but the actual date.That said, I've seen numerous examples in ATG when trying to pass the date in via a free-text field that ends up with unnecessary errors in the back end, even when you pass the 'date' format along. Most implementations, that work, will format the date with something like the jQuery
DatePicker
library and pass it to ATG as aString
value. In your formhandler you then implement a validation method that will parse theString
for being a valid date and return the appropriate exception. Your approach above is fraught with danger.