Well, I think I finally figured all this stuff out. It sure wasn't clear from any of the documentation I looked at. I'm not slamming the documenters out there b/c I know how it is. I just thought somewhere I'd find a clear explanation on this. I think the sub-application feature is one of the best things about Struts 1.1: Here's what you need to know:
1) Whatever key name you specify for a "message-resource" in a sub-app config file (e.g. SUB_APP_A_MESSAGES_KEY in my example below) gets a "/" plus the module name concantenated to it. So in my example, the message resource object (properties) gets stored in application scope under the key name "SUB_APP_A_MESSAGES_KEY/sub-app-a". 2) In your JSP file, if you want to use the <html:errors> tag and the error messages are in a sub-app's message resource file, you'll need to specify the resource bundle. For example: <html:errors bundle="SUB_APP_A_MESSAGES_KEY/sub-app-a" /> Be sure to include the errors.header, errors.footer, errors.prefix, and errors.suffix key/value pairs each sub-app's message resource file if you're using the <html:errors> tag. This was one thing I don't like about this approach. These header keys are duplicated across files -- if you're placing error messages for each sub-app in the corresponding message resource file. Unless I'm missing something, I think these header keys must be in the same file as the error message. 3) To write text in a JSP from a sub-app's message resource file, be sure to include the sub-app bundle: <bean:message key="copyright.notice" bundle="SUB_APP_A_MESSAGES_KEY/sub-app-a"/> Note: ----- Now that I understand the naming convention for the keys to store/retrieve message resources by sub-app, I thought my convention was redundant. Therefore I changed the key name in ALL my sub-app config files to just be "MESSAGE". For example: <message-resources key="MESSAGE" parameter="com.abc.training.LoginMessages" null="false"/> This will result in key names as follows: MESSAGE/sub-app-a MESSAGE/sub-app-b MESSAGE/sub-app-c ... Whew! I finally got this working!! JOHN -----Original Message----- From: Hohlen, John Sent: Tuesday, September 10, 2002 12:56 PM To: 'Struts Users Mailing List' Subject: RE: Question: Configuring Multiple <message-resources> Elements W ith Sub-Applications Whoops! In my examples below, the <action> tags should actually be <action-mappings>. That was a cut-and-paste error on my part and not relevant to this problem. I fixed the examples in this reply. -----Original Message----- From: Hohlen, John Sent: Tuesday, September 10, 2002 11:43 AM To: Struts-Help (E-mail) Cc: '[EMAIL PROTECTED]' Subject: Question: Configuring Multiple <message-resources> Elements With Sub-Applications If I'm using multiple message resource files with sub-applications, do I need declare all the message resource files in the default struts config file or do I declare each message resource file in the corresponding sub-app's struts config file? I searched the mailing lists, Struts documentation, and the online chapter's in Chuck Cavaness' upcoming Struts book (O'Reilly). I have not found a clear example on how to do this. Example #1 - Declaring All Message Resources In struts-config.xml: ================================================================= --- struts-config.xml----- <struts-config> <message-resources parameter="com.abc.training.Messages" null="false"/> <message-resources key="SUB_APP_A_MESSAGES_KEY" parameter="com.abc.training.SubAppAMessages" null="false"/> </struts-config> --- struts-config-sub-app-a.xml----- <struts-config> <form-beans> ... </form-beans> <action-mappings> ... </action-mappings> </struts-config> Example #2 - Declaring Each Message Resource In Each Sub App's struts-config-xml: ============================================================================ ==== --- struts-config.xml----- <struts-config> <message-resources parameter="com.abc.training.Messages" null="false"/> </struts-config> --- struts-config-sub-app-a.xml----- <struts-config> <form-beans> ... </form-beans> <action-mappings> ... </action-mappings> <message-resources key="SUB_APP_A_MESSAGES_KEY" parameter="com.abc.training.SubAppAMessages" null="false"/> </struts-config> I can't get either approach to work. If I use approach #1, error keys are not properly located for errors placed in the errors container by sub-application A. Hence, error mesages appear as "???en_US.<key>???. But this approach does work for JSP text retrieved from sub-app A's message resource file (as long as I specify the "bundle" attribute). If I use approach #2, I get the following exception (WebLogic 6.1 with SP2 or SP3): javax.servlet.ServletException: Cannot find message resources under key SUB_APP_A_MESSAGES_KEY at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImp l.java:256) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:10 14) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProces sor.java:417) at org.apache.struts.action.RequestProcessor.processActionForward(RequestProces sor.java:390) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:271) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292) at com.erac.fleetsystems.strutsx.FleetSystemsServlet.process(FleetSystemsServle t.java:178) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java :265) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java :200) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo ntext.java:2495) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java :2204) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) I believe approach #2 makes the most sense, but I keep getting the above servlet exception. FYI - I have the folllowing in my web.xml file for either approach: <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>config/subAppA</param-name> <param-value>/WEB-INF/struts-config-sub-app-a.xml</param-value> </init-param> Thanks in advance for your help. JOHN HOHLEN -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>