File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts Modules Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Modules" Watch "Struts Modules" New topic
Author

Struts Modules

Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
The project that I have been working on for the past few years started with Struts 1.0. This project has grown and our single struts-config file now has 306 form-bean definitions and 1612 action definitions. This has actually not been a huge problem. We have version control setup to allow multiple checkouts and even a lowly tool like Visual Source Safe is pretty good at merging changes to an xml document. The project occasionally needs to do work on a branch, and it is a bit of a pain trying to merge two struts-config files that have had numerous changes (something that I am doing now).

I do think that splitting our monstrous config file up into multiple files would generally be a good thing. Looking at the Struts documentation I see that I can specify a single module with multiple configuration files, or I can create multiple modules each with their own configuration file. I have read a few articles about configuring modules, but there are a few things that I do not understand.

Does the module name always appear in the URL? If I create an entry for "config/catalog" will my url look like "xyz.com/app/catalog/purchase.do"? I take it that this module name also shows up in my html:form tags.

I also do not fully understand the functionality or need for the SwitchAction. I also do not really understand was it means to switch from one module to another. It seems like I just need to specify contextRelative="true" in the forward and include the module as the first part of the path.

What about tiles-def and resource files? Can those be split up as well?

- Brent
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Wow, 1612 actions! That's quite an application.

I haven't used modules much either, but I've played around with them a little. At the risk of being the blind leading the blind, I'll take a stab at your questions.

Does the module name always appear in the URL?
If I create an entry for "config/catalog" will my url look like "xyz.com/app/catalog/purchase.do"? I take it that this module name also shows up in my html:form tags.


The answer is yes to all of the above.

I also do not fully understand the functionality or need for the SwitchAction. I also do not really understand was it means to switch from one module to another. It seems like I just need to specify contextRelative="true" in the forward and include the module as the first part of the path.


I'm with you on this one, Brent. I don't really see the need for SwitchAction either. There are easier ways of switching modules

What about tiles-def and resource files? Can those be split up as well?


Since the location and name of these resources are defined in each module's configuration file, you have the choice of having each of your configuration files point to the same resource, or having them each point to separate resources. The same goes for validation definitions.


Merrill
Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Thanks for the input. Before I advocate that we divide up the application I will play around a little with modules for new development. The last 3 Struts based applications that I have worked on started with 1.0, and none of them have switched over to using modules.

- Brent
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Modules
 
Similar Threads
Regarding web.xml
Multiple struts config files and multiple modules
Get rid of line numbers
Struts Lovers, explain this.
using tiles & validator across modules