-
Feb 10th, 2011, 10:57 AM
#1
Highlighting fields when validating using @AssertTrue
Hi,
Spring + Hibernate JSR303 successfully validates an assertion on two fields using @AssertTrue method. On the top of my JSP page, the message got displayed. Is there a way to specify that one or both of the related fields are highlighted?
I believe I can do this by intercepting in my controller, changing the value of the FieldError with field="lowerThresholdSmallerThanUpperThreshold" to field ="lowerThreshold"
Is there another/better way to handle this?
Thanks.
Tan
Pojo.java
@AssertTrue(message="{lowerThreshold.smallerThan.u pperThreshold}")
public boolean isLowerThresholdSmallerThanUpperThreshold () {
return lowerThreshold<upperThreshold;
}
JSP:
<div id="alert">
<form:errors path="lowerThresholdSmallerThanUpperThreshold" element="div" cssClass="error"/>
</div>
<div class="formRow">
<label for="lowerThreshold" class="formLabel"><spring:message code="label.lowerThreshold"/>:</label>
<span class="formElement">
<form:input path="lowerThreshold" class="small" cssErrorClass="formFieldWithError"/>
<span class="formElementDesc"><spring:message code="units.lowerThreshold"/></span>
</span>
</div>
<div class="formRow">
<label for="upperThreshold" class="formLabel"><spring:message code="label.upperThreshold"/>:</label>
<span class="formElement">
<form:input path="upperThreshold" class="small" cssErrorClass="formFieldWithError"/>
<span class="formElementDesc"><spring:message code="units.upperThreshold"/></span>
</span>
</div>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules