I have a form with a date input field. This field is NOT mandatory, this
means it can contain a value or be empty.
Whenever the user does NOT fill in this datefield I get the following
exception:
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:805)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.commons.beanutils.ConversionException
org.apache.commons.beanutils.converters.SqlDateConverter.convert(SqlDateConverter.java:117)
org.apache.commons.beanutils.ConvertUtilsBean.convert(ConvertUtilsBean.java:428)
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1004)
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
My form is defined as follows:
<form-bean name="vehicleForm" type="ch.smartsol.struts.form.VehicleForm"/>
and in Java:
public class VehicleForm extends ValidatorActionForm
{
...
private Date dateOfCommissioning = null;
...
}
OK, the form member is of type Java.sql.Date and the form sends a String.
Questions:
==========
- WHEN does the conversion from string to Date take place?
- How can I deal with empty strings in case the user does NOT fill in
this date field?
Many thanks for your help!
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]