You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lance Semmens <la...@swebtec.com> on 2005/08/12 17:41:29 UTC

Modularizing struts-config.xml

Is there any way to break up struts-config.xml into multiple xml files?
I'd like to be able to logically group my form and action mappings in
separate files.

________________________
Lance Semmens
Software Engineer

Swebtec
12 Hurlingham Business Park
Sulivan Road
London SW6 3DU
Tel: 0207 471 8121
www.swebtec.com <http://www.swebtec.com/>  



Re: Modularizing struts-config.xml

Posted by Leon Rosenberg <st...@anotheria.net>.
> Yes, you can use any number of struts-config files; there is a 
> servlet init parameter which accepts a comma-separated list.
> 
>        <param-name>config</param-name>
>        <param-value>
>              /WEB-INF/struts-config.xml,
>              /WEB-INF/admin/struts-config.xml,
>              /WEB-INF/approval/struts-config.xml,
> ...
> </param-value>
> 

is it an 1.1 feature or only available in later versions?

regards
leon



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Modularizing struts-config.xml

Posted by Joe Germuska <Jo...@Germuska.com>.
At 11:44 AM +0530 8/18/05, sachin wrote:
>hi ,
>
>>  Yes, you can use any number of struts-config files; there is a
>>  servlet init parameter which accepts a comma-separated list.
>
>I Have many struts-config files in one of my application and i 
>initialized them with a comma separeted List ...
>EveryThing Works fine until it comes to ActionMessages ....
>
>In each struts-config file i defined the message-resources with a 
>Key and accesssed them with that Key ...
>
><message-resources key="master"
>   parameter="org.para.resources.master.MasterMessageResources" 
>null="false" /> 
>
>But the ActionMessage could not pick up messages from resource files 
>which gave the biggest blow to my software and i had to show 
>messages with JavaScript.
>
>could u please tell me how to Make the ActionMessages work with 
>Multiple Struts Config file

If you use "key" when defining a message resources file, then you 
must use the same value in the "bundle" attribute when using JSP tags 
which are meant to retrieve messages.  As in:

<html:messages bundle="master" id="msg">${msg}</html:messages>

I've never needed to use more than one message-resources element in a 
project, so I haven't spent much time using these features, but 
that's how it works.  If you are not specifying a "bundle" in 
<html:messages> or <html:errors> then Struts will look for a 
<message-resources> which was configured without any "key" attribute.

See:
http://struts.apache.org/userGuide/configuration.html#resources_config 
http://struts.apache.org/userGuide/struts-html.html#messages

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Modularizing struts-config.xml

Posted by sachin <sa...@paradyne.co.in>.
hi ,

> Yes, you can use any number of struts-config files; there is a 
> servlet init parameter which accepts a comma-separated list.

I Have many struts-config files in one of my application and i initialized them with a comma separeted List ...
EveryThing Works fine until it comes to ActionMessages ....

In each struts-config file i defined the message-resources with a Key and accesssed them with that Key ...

<message-resources key="master" 
  parameter="org.para.resources.master.MasterMessageResources" null="false" /> 

But the ActionMessage could not pick up messages from resource files which gave the biggest blow to my software and i had to show messages with JavaScript.

could u please tell me how to Make the ActionMessages work with Multiple Struts Config file 

> Joe 

sachin

cheers , 
Sachin Hegde 
Paradyne Infotech Limited , Mumbai 
919324546711 

"Once freedom has exploded in the soul of man, the gods no longer have any 
power over him" Sartre- The Flies

---------- Original Message -----------
From: Joe Germuska <Jo...@Germuska.com> 
To: "Lance Semmens" <la...@swebtec.com>, <us...@struts.apache.org> 
Sent: Fri, 12 Aug 2005 10:59:00 -0500 
Subject: Re: Modularizing struts-config.xml 

> At 4:41 PM +0100 8/12/05, Lance Semmens wrote: 
> >Is there any way to break up struts-config.xml into multiple xml files? 
> >I'd like to be able to logically group my form and action mappings in 
> >separate files. 
> 
> Yes, you can use any number of struts-config files; there is a 
> servlet init parameter which accepts a comma-separated list. 
> 
>       <param-name>config</param-name> 
>       <param-value> 
>             /WEB-INF/struts-config.xml, 
>             /WEB-INF/admin/struts-config.xml, 
>             /WEB-INF/approval/struts-config.xml, 
> ... 
> </param-value> 
> 
> We have become very comfortable with a structure like the above which 
> partitions the application into packages which are roughly analogous 
> to use cases, or small sets of use cases.  the root struts-config.xml 
> holds things like plugin definitions and global exception handling, 
> then each sub-directoried file holds the related action mappings and 
> action forms for that package. 
> 
> The same sub-directory also contains tiles-definition.xml, 
> validation.xml, and spring-config.xml files (we use Spring to inject 
> dependencies into our controllers).  (Of course, you have to add the 
> pointers to these files manually in a few places; some kind of 
> autodiscovery would be nice, but it's not that much work...) 
> 
> Then we have an analogously structured Java package naming for 
> controllers and related code: 
> 
> foo.project.prefix.webui.admin.* 
> foo.project.prefix.webui.approval.* 
> 
> and we strictly use action mapping paths that also match this pattern: 
> 
> /admin/AdminHome.do 
> /admin/AdminSubtask.do 
> /approval/ApprovalHome.do 
> /approval/SubmitApproval.do 
> 
> and more of the same for JSPs, etc.  We find that it means that even 
> someone completely new to a project can zero in on an area of concern 
> extremely efficiently.  I think it's one of the reasons that I don't 
> really see Struts as nearly as much "XML Hell" as some detractors do. 
> 
> Joe 
> 
> -- 
> Joe Germuska             
> Joe@Germuska.com   
> http://blog.germuska.com     
> "Narrow minds are weapons made for mass destruction"  -The Ex 
> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org 
> For additional commands, e-mail: user-help@struts.apache.org 
------- End of Original Message -------



Re: Modularizing struts-config.xml

Posted by Joe Germuska <Jo...@Germuska.com>.
At 4:41 PM +0100 8/12/05, Lance Semmens wrote:
>Is there any way to break up struts-config.xml into multiple xml files?
>I'd like to be able to logically group my form and action mappings in
>separate files.

Yes, you can use any number of struts-config files; there is a 
servlet init parameter which accepts a comma-separated list.

       <param-name>config</param-name>
       <param-value>
             /WEB-INF/struts-config.xml,
             /WEB-INF/admin/struts-config.xml,
             /WEB-INF/approval/struts-config.xml,
...
</param-value>

We have become very comfortable with a structure like the above which 
partitions the application into packages which are roughly analogous 
to use cases, or small sets of use cases.  the root struts-config.xml 
holds things like plugin definitions and global exception handling, 
then each sub-directoried file holds the related action mappings and 
action forms for that package.

The same sub-directory also contains tiles-definition.xml, 
validation.xml, and spring-config.xml files (we use Spring to inject 
dependencies into our controllers).  (Of course, you have to add the 
pointers to these files manually in a few places; some kind of 
autodiscovery would be nice, but it's not that much work...)

Then we have an analogously structured Java package naming for 
controllers and related code:

foo.project.prefix.webui.admin.*
foo.project.prefix.webui.approval.*

and we strictly use action mapping paths that also match this pattern:

/admin/AdminHome.do
/admin/AdminSubtask.do
/approval/ApprovalHome.do
/approval/SubmitApproval.do

and more of the same for JSPs, etc.  We find that it means that even 
someone completely new to a project can zero in on an area of concern 
extremely efficiently.  I think it's one of the reasons that I don't 
really see Struts as nearly as much "XML Hell" as some detractors do.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org