Hello,
I don't know how to display errors in the jsp input page when using Struts
Validator. This is my case:
- validation.xml
...
<formset>
<form name="getNameForm">
<field property="name" depends="required">
<arg0 key="Name" resource="false"/>
</field>
<field property="phone" depends="required, mask">
<msg key="Phone number" name="mask" resource="false"/>
<arg0 key="A phone number" resource="false"/>
<var>
<var-name>mask</var-name>
<var-value>^(\d{3}-\d{3}-\d{4})|(\(\d{3}\)
?\d{3}-\d{4})$</var-value>
</var>
</field>
</form>
</formset>
...
- struts-config.xml
...
<form-beans>
<form-bean name="getNameForm" type="GetNameForm"/>
</form-beans>
<action-mappings>
<action input="/inputname.jsp" name="getNameForm" path="/greeting"
scope="request" type="GreetingAction" validate="true">
<forward name="greeting" path="/greeting.jsp"/>
</action>
</action-mappings>
<message-resources parameter="MyMessageResources"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
...
- validator-rules.xml isn't changed.
- GetNameForm.java
public class GetNameForm extends ValidatorForm {
private String name;
private String phone;
... getter, setter methods
My questions are:
1. How can I dislay the errors in the input jsp file when the name and phone
values don't meet the requirement?
2. Can I have the reset method in the Form Bean? If I can't, how can I reset
those values?
3. When I run it with the invalid values for name or phone, Struts forwards me
to the jsp input page but the address in the address bar is greeting.do. How
can I make it inputname.jsp?
Sincerely,
Thai
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]