Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Validator Framework - using same formbean for different jsps

 
Karthik Revanasiddan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  •  
    Manuel Jordan
    Ranch Hand
    Posts: 131
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hello guys

    an excelent example is here

    regards
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic