I was looking at JSF and Spring and comparing the spring:bind with the JSF state management.
I was curious about how Spring maintains form values to repopulate the html form upon a failed validation.
For example:
I have a date field and the user enters the value 01/02/3. The submit button is pressed and the request is routed to the controller. Validation is called and fails. So, the controller directs back to the form page with errors. Does spring maintain the failed user input value so that the date field is populated with the 01/02/3 (which is desirable) or does it look into the model object for a value and populate it as empty? Looking at the docs I was curious as to what status is and how and where it is created and maintained. All I have seen in the Controller is the ability to call BindUtils.bindAndValidate which returns a BindException that then can be used to extract the model from and passed back in the returning ModelAndView object. Is that where the status is created? Sorry if this is a lame question. But, Im trying to understand the internal workings so that I can better understand the end behavior.
--- example from docs ---
<spring:bind path="Company.name">
## render a form field, containing the value, the expression
Name: <input
type="text"
value="<c:out value="${status.value}"/>"
name="<c:out value="${status.expression}"/>">
## if there are error codes, display them!
<c:if test="${status.error}">
Error codes:
<c:forEach items="${status.errorMessages}" var"error">
<c:out value="${error}"/>
</c:forEach>
</c:if>
</spring:bind>


Reply With Quote