Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ValidatorActionForm

Status
Not open for further replies.

jsulman

Programmer
Jun 14, 2001
85
US
Has anybody gotten the Struts ValidatorActionForm to work?

I have two actions that use the same form and each action uses different elements of the form. From what I understand the ValidatorActionForm should take care of this by allowing me to map the action name to the validation process instead of the form name.

Here is what I have done:
1) Make my Form a sub class of the ValidatorAction Form;
public class SearchForm extends ValidatorActionForm {

2) Declare my action in the struts-config.xml:
<action path="/search"
type="org.apache.struts.actions.ForwardAction"
name="searchForm"
scope="request"
input=""
validate="true"
parameter="/ui/Search.jsp>
</action>
3) Specify the action as the form name to be validated.

<form name="/search">
<field property="filedDateFrom"
depends="date,mask">
<arg0 key="label.fromDate"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9]*$</var-value>
</var>
</field>
</form>

I have no validation method in the form and I have tried many combinations for the form name action "search", "/search.action", "search.action" and so forth.

What happens is it skips the validation. If I put the form name in there it works fine.

Any ideas?

Thank You in advance

Jeff Sulman
 
Everything seems to be correct up until the last or third point. Why are u validating the action ? The validation is meant for the form bean attributes/fields. Revised should be the following:

<form name="myForm">
<field property="filedDateFrom"
depends="date,mask">
<arg0 key="label.fromDate"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9]*$</var-value>
</var>
</field>
</form>

This is all being done in the validation.xml file right ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top