paulf
Nov 30th, 2004, 11:33 AM
Hello, I've searched the forum and cannot find a satisfactory answer.
I have an abstractCommandController with validator and command object. The comman object holds to fields java.sql.Timestamp.
I simply want to allow the user to enter two dates in the form dd/MM/yyyy and bind this into the command object.
I have tried registrating custom editors in the initBinder method
protected void initBinder(HttpServletRequest req, ServletRequestDataBinder binder) throws Exception
{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
dateFormat.setLenient(false);
binder.registerCustomEditor(java.sql.Date.class, new CustomDateEditor(dateFormat, true));
binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(dateFormat, true));
binder.registerCustomEditor(java.sql.Timestamp.cla ss, new CustomDateEditor(dateFormat, true));
}
Out of desperation I've registered all 3 Date type classes since I keep getting the error message
javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "value" with value "${status.value}": Attempt to convert String "23/11/2004" to type "java.util.Date", but there is no PropertyEditor for that type (null)
I am totally missing something? I cannot find any good documentation in this area. I'll be quite happy to read some if someone directs me please.
The error is occurring when the jsp is rendered using
<spring:bind path="command.effFromDate">
<td>From Date</td><td><input type="text" name="<c:out value="${status.expression}"/>" value="<fmt:formatDate value="${status.value}" pattern="dd/MM/yyyy"/>"/></td>
</spring:bind>
<td></td>
<spring:bind path="command.effToDate">
<td>To Date</td><td><input type="text" name="<c:out value="${status.expression}"/>" value="<fmt:formatDate value="${status.value}" pattern="dd/MM/yyyy"/>"/></td>
</spring:bind>
Any help would be appreciated. Thanks.
I have an abstractCommandController with validator and command object. The comman object holds to fields java.sql.Timestamp.
I simply want to allow the user to enter two dates in the form dd/MM/yyyy and bind this into the command object.
I have tried registrating custom editors in the initBinder method
protected void initBinder(HttpServletRequest req, ServletRequestDataBinder binder) throws Exception
{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
dateFormat.setLenient(false);
binder.registerCustomEditor(java.sql.Date.class, new CustomDateEditor(dateFormat, true));
binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(dateFormat, true));
binder.registerCustomEditor(java.sql.Timestamp.cla ss, new CustomDateEditor(dateFormat, true));
}
Out of desperation I've registered all 3 Date type classes since I keep getting the error message
javax.servlet.jsp.JspException: An error occurred while evaluating custom action attribute "value" with value "${status.value}": Attempt to convert String "23/11/2004" to type "java.util.Date", but there is no PropertyEditor for that type (null)
I am totally missing something? I cannot find any good documentation in this area. I'll be quite happy to read some if someone directs me please.
The error is occurring when the jsp is rendered using
<spring:bind path="command.effFromDate">
<td>From Date</td><td><input type="text" name="<c:out value="${status.expression}"/>" value="<fmt:formatDate value="${status.value}" pattern="dd/MM/yyyy"/>"/></td>
</spring:bind>
<td></td>
<spring:bind path="command.effToDate">
<td>To Date</td><td><input type="text" name="<c:out value="${status.expression}"/>" value="<fmt:formatDate value="${status.value}" pattern="dd/MM/yyyy"/>"/></td>
</spring:bind>
Any help would be appreciated. Thanks.