wood burning stoves 2.0*
The moose likes Struts and the fly likes How to use same rules for different ActionForms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use same rules for different ActionForms" Watch "How to use same rules for different ActionForms" New topic
Author

How to use same rules for different ActionForms

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
I have two ActionForm beans.I am specifying validation rules inside
validation.xml file.
Both beans are using same kind of rules.
Inside validation.xml file i am writing rules as shown below


//for bean 1
<formset >
<form name="ContentActionForm">
.....
<!--field property rules are same as bean 2-->
.....
</formset >

//for bean 2
<formset >
<form name="RegUserActionForm">
.....
<!--field property rules are same as bean 1-->
.....
</formset >

As show above i have specified same set of rules twice of two different
beans.
Is it not possible to attach different beans to same set of rules?
For example some thing like this
<form name="RegUserActionForm,ContentActionForm">
or
<form name="RegUserActionForm","ContentActionForm">

Thanks
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Unfortunately, I don't know of a way to reuse validation rules set up for one form for another. In my mind that has always been one of the weaknesses of the validation framework.


Merrill
Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Once again I completely agree with Merrill's post. Sometimes I think it is easier and cleaner just to implement the validate method.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use same rules for different ActionForms
 
Similar Threads
Struts Validator With Modules
LookupDispatch action with validator
Multipage form validation
How to check if field exist in validation.xml
What Are the Causes for Validation Not Doing Anything?