You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin HaleBoyes <kz...@yahoo.com> on 2002/11/28 17:54:21 UTC
how to handle empty form fields
I have a form field that is to represent a Date value.
I input it using a <html:text> tag
<html:text property="assignedDate" size="12"/>
and it corresponds to a String field in the form bean.
It is an optional field and not usually filled in.
In the business logic I call
BeanUtils.copyProperties(lrdto, lrform);
to copy from the form bean to the DTO. In the DTO the
assignedDate property has the type java.sql.Date.
When the field is left empty on the form I get a
org.apache.commons.beanutils.ConversionException exception
from copyProperties() that was generated by SqlDateConverter.
I'm wondering how to avoid the exception.
If I set a value into the field before I submit the form then
it works fine. I only run into the exception when I leave the
field blank but my business requirements state that this field
is optional.
There are a __lot__ of questions regarding Date input and
validation in the archives but I didn't find anything about
this exception or optional Date fields.
Thanks for any help,
Kevin.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>