My form uses the Struts validator. One of its fields is 'required' and I
want the error message to show up alongside the field when the form is
redisplayed. There may also be general errors and I want these to be listed
at the top of the page. Problem is, the field  specific error (created by
the validator framework) gets displayed alongside the field (correctly) AND
as a general error at the top of the page! I don't understand this; the
error message must be associated with a field property otherwise it wouldn't
show up alongside the field, so why is it also being treated as a general
error?

The relevant snippets from my code are below.

Any help gratefully received.

David
--

[-------- struts-config.xml --------]
<form-bean name="areaHierarchyForm" 
  type="org.apache.struts.validator.DynaValidatorForm">
        <form-property name="name" type="java.lang.String"/>
        ...
</form-bean>
...
<action
                path="/area-hierarchy/submit"
                type="com.acme.UpdateAreaHierarchyAction"
                name="areaHierarchyForm"
                scope="session"
                validate="true"
                input="/AreaHierarchy.jsp">
         <forward name="continue" path="/AreaHierarchy.jsp"/>
         <forward name="success" path="/area-hierarchy/list.do"/>
</action>


[-------- validation.xml --------]
<form name="areaHierarchyForm">
        <field property="name" depends="required">
                <arg0 key="areaHierarchyForm.name"/>
        </field>
</form>


[-------- MessageResources.properties --------]
areaHierarchyForm.name=Hierarchy Name


[-------- AreaHierarchy.jsp --------]
...
<!-- #### General error messages #### -->
<logic:messagesPresent>
        <span class="error"><bean:message
key="errors.validation.header"/></span>
        <ul class="error">
                <html:messages id="error">
                        <li><c:out value="${error}"/></li>
                </html:messages>
        </ul>
</logic:messagesPresent>

<html:form action="/area-hierarchy/submit">
        <html:text styleId="name" property="name"/>
        <!-- #### Field specific error message #### -->
        <span class="error"><html:errors property="name"/></span>
...


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to