Hello,
The new Spring 2.0 MVC <form> tag has been working fine for me, but I'm having difficulty trying to get this tag to work properly within a JSP 2.0 tag file.
Directly within a JSP page, the following code snippet works fine:
Since this code is repeated in many input fields in many JSP files, I wanted to factor this into a JSP 2.0 tag file, similar to the process described on pages 185-190 of Seth Ladd's Expert Spring MVC Book by APress.Code:<tr> <td colspan=2 class="validationError"><form:errors path="paidDateFrom"/></td> </tr> <tr> <td><fmt:message key="paidDateFrom.label"/></td> <td><form:input path="paidDateFrom" size="10"/></td> </tr>
Here is my JSP 2.0 tag file that replaces the above in my JSP file:
I know the tag file call above works because if my formField.tag tag file just outputs ${path}, ${label}, and ${size}, I get the three field values I gave above.Code:<tag:formField path="paidDateFrom" label="paidDateFrom.label" size="10"/>
But with my actual tag file code below, it is failing on the form:errors and form:input tags. Something seems wrong with the scoping, form:errors and form:input appear to no longer be able to identify the parent command bean when I place them in a tag file:
Here's the error code I'm getting back from Tomcat 5.5 on this:Code:<%@ tag body-content="scriptless" %> <%@ attribute name="path" required="true" %> <%@ attribute name="label" required="true" %> <%@ attribute name="size" required="true" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <tr> <td colspan=2 class="validationError"><form:errors path="${path}"/></td> </tr> <tr> <td><fmt:message key="${label}"/></td> <td><form:input path="${path}" size="${size}"/></td> </tr>
Can anyone see what I'm doing wrong here?Code:java.lang.IllegalStateException: Neither Errors instance nor plain target object for bean name 'null' available as request attribute org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:134) org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:150) org.springframework.web.servlet.tags.form.ErrorsTag.shouldRender(ErrorsTag.java:42) org.springframework.web.servlet.tags.form.ErrorsTag.writeTagContent(ErrorsTag.java:50) org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:82) org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:68) org.apache.jsp.tag.web.formField_tag._jspx_meth_form_errors_0(org.apache.jsp.tag.web.formField_tag:141) org.apache.jsp.tag.web.formField_tag.doTag(org.apache.jsp.tag.web.formField_tag:101) ...
Thanks,
Glen


Reply With Quote