wood burning stoves*
The moose likes Struts and the fly likes Struts Validator Framework - using same formbean for different jsps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validator Framework - using same formbean for different jsps" Watch "Struts Validator Framework - using same formbean for different jsps" New topic
Author

Struts Validator Framework - using same formbean for different jsps

Karthik Revanasiddan
Greenhorn

Joined: Nov 24, 2006
Posts: 8
Hi,

How to map a set of validations in validation.xml file for two actions defined which use the same Form Bean, each will have a unique action path.

regards,
karthik.
prasanth jalasutram
Greenhorn

Joined: Dec 15, 2004
Posts: 6
validation rules are not restricted to any action rather to a actionform.So you can use the same validation rules for diff actions if both actions are using same action form.

For Example:
<form-validation>
<formset>
<form name="checkoutForm">
<field
property="firstName"
depends="required">
<arg0 key="label.firstName"/>
</field>

<field
property="lastName"
depends="required">
<arg0 key="label.lastName"/>
</field>
</form>
</formset>
</form-validation>

Thanks
Prashant
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you want the same validations to be performed for both actions, you don't have to do anything. As Prasanth pointed out, you just define the validation rules for the form and the validations will be performed for both actions.

If you want the validation rules to be different for each action, do the following:
  • Have your ActionForm extend ValidatorActionForm instead of ValidatorForm
  • In the validation.xml file, specify the action path rather than the form name in the <form name= > stanza.
  • Create entries for each action


  • Merrill
    Consultant, Sima Solutions
    Manuel Jordan
    Ranch Hand

    Joined: Sep 29, 2006
    Posts: 131
    Hello guys

    an excelent example is here

    regards


    kill your pride, share your knowledge with all
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Struts Validator Framework - using same formbean for different jsps
     
    Similar Threads
    Finding null or blank string
    Case in DTD
    array declaration
    IBM free testing opportunity...
    Barry Boone's Question