PDA

View Full Version : select/options Error message not displaying Spring MVC 2.5 form



jamesEston
Feb 14th, 2011, 03:10 PM
Hello All,
I am trying to get an error message to display next to a dropdown list of dates if the user doesn't select at least one date.
I have the following jsp code:
<form:select path="selectedDatesList" >
<c:forEach var="item" items="${prevDatesList}">
<option>
<fmt:formatDate pattern="MM/dd/yyyy" value="${item}" /> </option>
</c:forEach>

<form:errors path="selectedDatesList" cssClass="error"></form:errors>
</form:select>
and in the message properties I use:
required.selectedDatesList=At least one date is required.

and in the validator method I have:
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "selectedDatesList", "required.selectedDatesList");

When I'm debugging in the validator method I see the error appear, but the message is never shown. However, after the submit, the form is shown again as if there was an error, there just isn't any message. This is working for the checkbox fields however, with similar code.:)

Any ideas as to what I'm doing wrong here?

Okay, I figured it out, I left in some validator code that didn't need to be there and that fixed it.
Thanks for looking.

Thanks,
James