You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Niall Pemberton <ni...@blueyonder.co.uk> on 2005/09/17 00:12:27 UTC
Multiple Struts Config / Multiple Validator Config
I had always assumed that (within the same module) I could break up my
validations.xml with my form definitions, for the same locale split accross
several files. But the way it works is that subsequent formsets just
overwite the ones already loaded. Validator and Constant definitions work
fine - they all get merged togther. Is this the intended/expected behaviour.
I would have expected them to all get merged.
Also, I thought that if I split up the struts-config I could have a
validator plugin definition in each of them associated with different parts
of the "broken" up validations.xml - but it appears that the last Validator
Plugin to run will overwite anything previous ones have loaded. Again is
this the intended/expected behaviour?
The way it works now, you can only have the Validator plugin defined once
even if you have multiple struts-config.xml for the same module and you can
only break up your form validations into different files for each Locale.
Is this correct or have I missed something?
Niall
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Multiple Struts Config / Multiple Validator Config
Posted by Laurie Harper <la...@holoweb.net>.
Joe Germuska wrote:
> At 2:17 PM -0400 9/17/05, Laurie Harper wrote:
>
>> On a slight tangent, what happens if you're using wild-card action
>> mapping paths? When Struts matches URLs against mapping paths the last
>> match wins, which means you have to be careful about the order you
>> define your actions in. In my application I have a general 'catch-all'
>> mapping with the path '/**' listed first and another with the path
>> '/**/' which simply redirects to '/{1}' (i.e. strips the trailing '/')
>> which, of course, has to be listed last.
>>
>> If I break up my struts-config.xml into multiple files I suspect I'm
>> going to have some problems with this ;-)
>
>
> Actually, it should be determinate, in for a single module, Struts
> processes the config files in the order in which they are specified in
> the servlet init parameter.
>
> It still might be confusing, but it should be determinate!
True; I was thinking about if I had multiple config files without using
modules, but I guess the same thing applies [except with modules I'd
need to repeat my pair or catch-all mappings for each module, of course].
Hmm, I guess I could have a pair of config files which contained one of
the mappings each and just make those the first and last files loaded,
though; I *think* I could even share the same two config files for each
module (I can't remember off-hand if the module name prefix ever has to
appear in the struts-config).
Cheers,
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Multiple Struts Config / Multiple Validator Config
Posted by Joe Germuska <Jo...@Germuska.com>.
At 2:17 PM -0400 9/17/05, Laurie Harper wrote:
>On a slight tangent, what happens if you're using wild-card action
>mapping paths? When Struts matches URLs against mapping paths the
>last match wins, which means you have to be careful about the order
>you define your actions in. In my application I have a general
>'catch-all' mapping with the path '/**' listed first and another
>with the path '/**/' which simply redirects to '/{1}' (i.e. strips
>the trailing '/') which, of course, has to be listed last.
>
>If I break up my struts-config.xml into multiple files I suspect I'm
>going to have some problems with this ;-)
Actually, it should be determinate, in for a single module, Struts
processes the config files in the order in which they are specified
in the servlet init parameter.
It still might be confusing, but it should be determinate!
Joe
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Multiple Struts Config / Multiple Validator Config
Posted by Laurie Harper <la...@holoweb.net>.
On a slight tangent, what happens if you're using wild-card action
mapping paths? When Struts matches URLs against mapping paths the last
match wins, which means you have to be careful about the order you
define your actions in. In my application I have a general 'catch-all'
mapping with the path '/**' listed first and another with the path
'/**/' which simply redirects to '/{1}' (i.e. strips the trailing '/')
which, of course, has to be listed last.
If I break up my struts-config.xml into multiple files I suspect I'm
going to have some problems with this ;-)
L.
Joe Germuska wrote:
> We routinely decompose all of our key struts config files into smaller
> units: struts-config, validation, and tiles-definitions. It is true
> that you can only define the validator plugin once, but when you define
> it, you can give it a list of configs. Our typical setup looks
> something like this:
>
> /WEB-INF/
> ...struts-config.xml
> ...tiles-definitions.xml
> ...validator-rules.xml
> ...validation.xml
> .../segment1/
> .../.../struts-config.xml
> .../.../tiles-definitions.xml
> .../.../valiidation.xml
> .../segment2/
> .../.../struts-config.xml
> .../.../tiles-definitions.xml
> .../.../valiidation.xml
>
> etc.
>
> We limit the "top-level" files to"infrastructure" work - mostly global
> definitions like "abstract" tiles definitions, validator constants,
> Struts global exception handling, etc. The "top-level" struts-config is
> the only one which defines validator and tiles plugins, and each of
> those points to all the necessary configuration files. Then each
> WEB-INF subdirectory organizes all the related concerns for the action
> paths with mappings that begin with that path (i.e. /segment1/Foo.do,
> /segment2/Bar.do). A bit of discipline here means that if you start
> from the actual action path, you can reliably find everything related to
> servicing that path with a minimum of consideration...
>
> So, in short, you can use multiple validation files; it's just that you
> can't use multiple Validator plugins in the same module.
>
> Joe
>
>
> At 9:15 PM -0500 9/16/05, Hubert Rabago wrote:
>
>> I haven't used multiple validations.xml files, but the behavior you
>> described with multiple struts-config matches what I would expect.
>>
>> I don't know exactly what would be needed to make validator work the
>> way you're expecting to, but it would likely require some cooperation
>> from ValidatorResources.
>>
>> Hubert
>>
>> On 9/16/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
>>
>>> I had always assumed that (within the same module) I could break up my
>>> validations.xml with my form definitions, for the same locale split
>>> accross
>>> several files. But the way it works is that subsequent formsets just
>>> overwite the ones already loaded. Validator and Constant definitions
>>> work
>>> fine - they all get merged togther. Is this the intended/expected
>>> behaviour.
>>> I would have expected them to all get merged.
>>>
>>> Also, I thought that if I split up the struts-config I could have a
>>> validator plugin definition in each of them associated with
>>> different parts
>>> of the "broken" up validations.xml - but it appears that the last
>>> Validator
>>> Plugin to run will overwite anything previous ones have loaded.
>>> Again is
>>> this the intended/expected behaviour?
>>>
>>> The way it works now, you can only have the Validator plugin defined
>>> once
>>> even if you have multiple struts-config.xml for the same module and
>>> you can
>>> only break up your form validations into different files for each
>>> Locale.
>>>
>>> Is this correct or have I missed something?
>>>
>>> Niall
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Multiple Struts Config / Multiple Validator Config
Posted by Joe Germuska <Jo...@Germuska.com>.
We routinely decompose all of our key struts config files into
smaller units: struts-config, validation, and tiles-definitions. It
is true that you can only define the validator plugin once, but when
you define it, you can give it a list of configs. Our typical setup
looks something like this:
/WEB-INF/
...struts-config.xml
...tiles-definitions.xml
...validator-rules.xml
...validation.xml
.../segment1/
.../.../struts-config.xml
.../.../tiles-definitions.xml
.../.../valiidation.xml
.../segment2/
.../.../struts-config.xml
.../.../tiles-definitions.xml
.../.../valiidation.xml
etc.
We limit the "top-level" files to"infrastructure" work - mostly
global definitions like "abstract" tiles definitions, validator
constants, Struts global exception handling, etc. The "top-level"
struts-config is the only one which defines validator and tiles
plugins, and each of those points to all the necessary configuration
files. Then each WEB-INF subdirectory organizes all the related
concerns for the action paths with mappings that begin with that path
(i.e. /segment1/Foo.do, /segment2/Bar.do). A bit of discipline here
means that if you start from the actual action path, you can reliably
find everything related to servicing that path with a minimum of
consideration...
So, in short, you can use multiple validation files; it's just that
you can't use multiple Validator plugins in the same module.
Joe
At 9:15 PM -0500 9/16/05, Hubert Rabago wrote:
>I haven't used multiple validations.xml files, but the behavior you
>described with multiple struts-config matches what I would expect.
>
>I don't know exactly what would be needed to make validator work the
>way you're expecting to, but it would likely require some cooperation
>from ValidatorResources.
>
>Hubert
>
>On 9/16/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
>> I had always assumed that (within the same module) I could break up my
>> validations.xml with my form definitions, for the same locale split accross
>> several files. But the way it works is that subsequent formsets just
>> overwite the ones already loaded. Validator and Constant definitions work
>> fine - they all get merged togther. Is this the intended/expected behaviour.
>> I would have expected them to all get merged.
>>
>> Also, I thought that if I split up the struts-config I could have a
>> validator plugin definition in each of them associated with different parts
>> of the "broken" up validations.xml - but it appears that the last Validator
>> Plugin to run will overwite anything previous ones have loaded. Again is
>> this the intended/expected behaviour?
>>
>> The way it works now, you can only have the Validator plugin defined once
>> even if you have multiple struts-config.xml for the same module and you can
>> only break up your form validations into different files for each Locale.
>>
>> Is this correct or have I missed something?
>>
>> Niall
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Multiple Struts Config / Multiple Validator Config
Posted by Hubert Rabago <hr...@gmail.com>.
I haven't used multiple validations.xml files, but the behavior you
described with multiple struts-config matches what I would expect.
I don't know exactly what would be needed to make validator work the
way you're expecting to, but it would likely require some cooperation
from ValidatorResources.
Hubert
On 9/16/05, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
> I had always assumed that (within the same module) I could break up my
> validations.xml with my form definitions, for the same locale split accross
> several files. But the way it works is that subsequent formsets just
> overwite the ones already loaded. Validator and Constant definitions work
> fine - they all get merged togther. Is this the intended/expected behaviour.
> I would have expected them to all get merged.
>
> Also, I thought that if I split up the struts-config I could have a
> validator plugin definition in each of them associated with different parts
> of the "broken" up validations.xml - but it appears that the last Validator
> Plugin to run will overwite anything previous ones have loaded. Again is
> this the intended/expected behaviour?
>
> The way it works now, you can only have the Validator plugin defined once
> even if you have multiple struts-config.xml for the same module and you can
> only break up your form validations into different files for each Locale.
>
> Is this correct or have I missed something?
>
> Niall
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org