Mark,
Here's what I do to achieve just what you are talking about:
I have a property in my ApplicationResources.properties file for "errors.present" and I display this message at the top of the page when there are errors. I use the logic tag to determine if there are errors present.
<logic:messagesPresent> <bean:message key="errors.present"/> </logic:messagesPresent>
Near the field that has an error, you put the following tag for the field in question. The property must match the property name you used in your validation.xml file.
<nested:errors property="email"/>
I hope that helps,
TR
Mark Benussi wrote:
As a Struts 1.0 developer I used to use the traditional struts methods for error messages e.g. saveErrors(). Ive moved (not so gracefully) to using Struts 1.1 and Validator. My simple problem is that I cant work out how to display the messages produced by the validator. I have included the validator rules and really just need the jsp code to get the messages out. Ideally I would like to be able to detect that there are error messages present and write out a general message and then place the specific message for each field next to the said field.
Here is the validation rule:
<form-validation>
<global></global>
<formset>
<!-- Submitted with a user registration request -->
<form name="registerUserForm">
<field property="firstName" depends="required">
<arg0 key="registerUserForm.firstName" />
</field>
<field property="surname" depends="required">
<arg0 key="registerUserForm.surname" />
</field>
<field property="password" depends="required,minlength">
<arg0 key="registerUserForm.password" />
<var>
<var-name>secondProperty</var-name>
<var-value>confirmPassword</var-value>
</var>
<arg1 name="minlength" key="${var:minlength}" resource="false" />
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
</field>
<field property="confirmPassword" depends="required,minlength,samefieldvalues">
<arg0 key="registerUserForm.confirmPassword" />
<var>
<var-name>secondProperty</var-name>
<var-value>password</var-value>
</var>
<arg1 name="minlength" key="${var:minlength}" resource="false" />
<var>
<var-name>minlength</var-name>
<var-value>6</var-value>
</var>
</field>
<field property="email" depends="required,email">
<arg0 key="registerUserForm.email" />
</field>
<field property="secretQuestion" depends="required">
<arg0 key="registerUserForm.secretQuestion" />
</field>
<field property="secretAnswer" depends="required">
<arg0 key="registerUserForm.secretAnswer" />
</field>
</form>
</formset>
</form-validation>
Appreciate your time.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]