Title: Common Resource bundles across web projects, ActionMessage and html:messages

Hi all,
We are using the ActionMessage-s with replacement values.

We want to divide the resource bundles so that we have a 'common-layout-jar' which contains common messages in 'GeneralMessages.properties' and so the application war itself contains *all application specific messages* in 'ApplicationResources.properties', the last one set up as the default bundle in struts-config.xml.

Generally, it seems that resource bundle texts from the default bundle *only* are accessible for an ActionMessage contructor by their key - (new ActionMessage(String key, Object o);)

Therefore, from our experience, all bundle texts with *replacement objects* specifically,  must be placed in the *default bundle*.

If not, the ActionMessage contructor with key (or possibly the <html:messages...> tag) and replacement values does not play - and an JspException is generated, see below.

Does anyone have a solution to this, we want to refer *directly* to message keys in common resource bundles instead of having to concatenating strings manually. (That is the workaround we found to work if we insist on having the common messages once and for all defined in the common layout jar.)

Thanks!

Regards,
Gudny H.

-----------------------------------------------------------------------------------
Code example:
In the Action-class:
 ActionMessages messages = new ActionMessages();
 ActionMessage("general.textWithOneReplacementValue", replacementValue);
 messages.add(Globals.MESSAGE_KEY, msg);

Message associated with the key in the resource bundle:
   general.textWithOneReplacementValue= Some message with one replacement value: '{0}'

The JSP code we used for outputting the messages is:
   <html:messages id="msg" message="true">
        <bean:write name="msg" /><br/>
   </html:messages>

If "general.textWithOneReplacementValue" property is placed in other than the default bundle, this JspException is generated:

2006-03-16 10:45:03,779 ERROR [[/nims-web-5.0-SNAPSHOT].[action]] Servlet.service() for servlet action threw exception javax.servlet.jsp.JspException: Cannot find bean: "msg" in any scope.

-----------------------------------------------------------------------------------


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

Reply via email to