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 [EMAIL PROTECTED] http://blog.germuska.com "Narrow minds are weapons made for mass destruction" -The Ex

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

Reply via email to