Re: Adding the ability to include a validation xml file from another inside another validation xml file in Struts2

2007-10-11 Thread Arup Francis

Hi Ian,

   I had looked into visitor validator earlier and had misunderstood it and
thought the top level model object had to be given for using visitor
validator but guess not. I looked it up more deeply and yes I am able to
remove the duplication of validation almost fully. An xml still need to be
created for each scenario but still the validation for a field resides in a
single file and so in case future we have to modify it it needs to be done
only at one location. 

But still I feel the ability to include one file within another would be a
welcome addition to validation in struts2.

Thanks for making me lookup visitor validator again!

Thanks  Regards,
Arup

 

Ian Roughley wrote:
 
 Have you looked at the visitor validator?  It might serve your purposes 
 if the fields are on objects in the action.
 
 /Ian
 
 Arup Francis wrote:
 Hi,

We have this problem of having to repeat certain validations for the
 same
 fields in multiple validation xml files because they occur in multiple
 scenarios and we have different validation files for the different
 scenarios. Now this brings about duplication of code in the sense that in
 future if I need to modify the validation for the fields then I have to
 do
 it in multiple files which is quite a pain. I was thinking that if it was
 possible to have the ability to include one validation file within
 another
 validation xml then it would help us in removing the duplication of code
 because I could define the validation for the fields in a single file and
 then include that file in the multiple scenario validation files.

 Its something like the s:include / that you have for the struts.xml
 using
 which you can include other struts configuration files.

 Struts 2 gurus - Please let me know on what you feel about this.
 Maybe this can be added as an enhancement in future versions of struts2.

 Arup
   
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Adding-the-ability-to-include-a-validation-xml-file-from-inside-another-validation-xml-file-in-Struts2-tf4601659.html#a13154537
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding the ability to include a validation xml file from another inside another validation xml file in Struts2

2007-10-11 Thread Arup Francis

Hi Laurie,

   The visitor validator is I believe the same thing (or almost similar) as
specifying validation rules against model classes. I was able to fix my
problem of duplication using that.

The BaseClass implementation will not work because I looked up the way the
validation xml's associated with a particular action is determined in the
validator interceptor and its based on the action name i.e. if SubBaseAction
is the action name then the interceptor will try to find out if any
validation xml's exist of the format SubBaseAction-*-validation.xml and so
it won't work if we have a validation file called
BaseAction-*-validation.xml. 

Arup



Laurie Harper wrote:
 
 I thought you could also specify validation rules against model classes 
 as well, which might help if the rules that are repeated are always the 
 same for a particular model property; I can't find mention of that 
 capability in the validation docs off-hand, though.
 
 You may also be able to leverage inheritance here; if you can give the 
 set of actions that need to share/duplicate validation rules a common 
 base class, you can specify those rules in BaseClass-validation.xml and 
 the sub-classes should pick them up.
 
 And if all else fails, there's always good old XML external entities. 
 You'd have to repeat the definition of the external entities at the head 
 of each *-validation.xml, but that's a lot less duplication than 
 repeating the actual rules.
 
 L.
 
 Ian Roughley wrote:
 Have you looked at the visitor validator?  It might serve your purposes 
 if the fields are on objects in the action.
 
 /Ian
 
 Arup Francis wrote:
 Hi,

We have this problem of having to repeat certain validations for 
 the same
 fields in multiple validation xml files because they occur in multiple
 scenarios and we have different validation files for the different
 scenarios. Now this brings about duplication of code in the sense that
 in
 future if I need to modify the validation for the fields then I have 
 to do
 it in multiple files which is quite a pain. I was thinking that if it
 was
 possible to have the ability to include one validation file within 
 another
 validation xml then it would help us in removing the duplication of code
 because I could define the validation for the fields in a single file
 and
 then include that file in the multiple scenario validation files.

 Its something like the s:include / that you have for the struts.xml 
 using
 which you can include other struts configuration files.

 Struts 2 gurus - Please let me know on what you feel about this.
 Maybe this can be added as an enhancement in future versions of struts2.

 Arup
   
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Adding-the-ability-to-include-a-validation-xml-file-from-inside-another-validation-xml-file-in-Struts2-tf4601659.html#a13154572
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding the ability to include a validation xml file from another inside another validation xml file in Struts2

2007-10-10 Thread Ian Roughley
Have you looked at the visitor validator?  It might serve your purposes 
if the fields are on objects in the action.


/Ian

Arup Francis wrote:

Hi,

   We have this problem of having to repeat certain validations for the same
fields in multiple validation xml files because they occur in multiple
scenarios and we have different validation files for the different
scenarios. Now this brings about duplication of code in the sense that in
future if I need to modify the validation for the fields then I have to do
it in multiple files which is quite a pain. I was thinking that if it was
possible to have the ability to include one validation file within another
validation xml then it would help us in removing the duplication of code
because I could define the validation for the fields in a single file and
then include that file in the multiple scenario validation files.

Its something like the s:include / that you have for the struts.xml using
which you can include other struts configuration files.

Struts 2 gurus - Please let me know on what you feel about this.
Maybe this can be added as an enhancement in future versions of struts2.

Arup
  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Adding the ability to include a validation xml file from another inside another validation xml file in Struts2

2007-10-10 Thread Laurie Harper
I thought you could also specify validation rules against model classes 
as well, which might help if the rules that are repeated are always the 
same for a particular model property; I can't find mention of that 
capability in the validation docs off-hand, though.


You may also be able to leverage inheritance here; if you can give the 
set of actions that need to share/duplicate validation rules a common 
base class, you can specify those rules in BaseClass-validation.xml and 
the sub-classes should pick them up.


And if all else fails, there's always good old XML external entities. 
You'd have to repeat the definition of the external entities at the head 
of each *-validation.xml, but that's a lot less duplication than 
repeating the actual rules.


L.

Ian Roughley wrote:
Have you looked at the visitor validator?  It might serve your purposes 
if the fields are on objects in the action.


/Ian

Arup Francis wrote:

Hi,

   We have this problem of having to repeat certain validations for 
the same

fields in multiple validation xml files because they occur in multiple
scenarios and we have different validation files for the different
scenarios. Now this brings about duplication of code in the sense that in
future if I need to modify the validation for the fields then I have 
to do

it in multiple files which is quite a pain. I was thinking that if it was
possible to have the ability to include one validation file within 
another

validation xml then it would help us in removing the duplication of code
because I could define the validation for the fields in a single file and
then include that file in the multiple scenario validation files.

Its something like the s:include / that you have for the struts.xml 
using

which you can include other struts configuration files.

Struts 2 gurus - Please let me know on what you feel about this.
Maybe this can be added as an enhancement in future versions of struts2.

Arup
  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]