Struts 2 Tip #4 - Within a namespace, reuse names for common concepts.
In practice, most applications are composed of a small number of workflows that repeat within the application. When configuration elements in different namespaces serve the same role, use the same identifier for each element. If each namespace includes a "Menu" or a "Help" action, use those same names with each namespace.
<struts> <package name="receivables" namespace="/receivables"> <action name="Menu" class="receivables.Menu" > <result>/receivables/Menu.jsp</result> </action> <!-- ... --> </package> <package name="payables" namespace="/payables"> <action name="Menu" class="payables.Menu" > <result>/payables/Menu.jsp</result> </action> <!-- ... --> </package> </struts>Since the namespace feature avoids collisions between element names, we can increase cohesion within the application by using a consistent naming pattern.
HTH, Ted.
Ted Husted is a software engineer and team mentor. His specialty is building agile web applications with open source products like Yahoo! User Interface Library, Struts, Spring, iBATIS, and MySQL, for either Java or Microsoft .NET, and helping others do the same.
Copyright Ted Husted 2007. All rights reserved.