struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "O'Shea, Sean" <Sean.O'S...@fmr.com>
Subject Resource bundles and Struts taglibs
Date Wed, 23 Aug 2006 14:43:55 GMT
Hi all,

I'm using struts 1.2.9 and I'm having some trouble with resource
bundles. My JSP looks like this:

<%@ include file="../taglibs.jsp" %>
<logic:messagesPresent>
	<h3 class="red"><bean:message key="errors.header"
bundle="otherBundle"/></h3>
	<bean:message key="errors.subheader" bundle="otherBundle" />
	<ul>
		<html:messages id="error">
			<li><bean:write name="error"
bundle="otherBundle" /></li>
		</html:messages>
	</ul>
	<hr>
</logic:messagesPresent>

I'm plugging my resources into my struts-config.xml like this:

<message-resources parameter="resources.ApplicationResources"
null="false"/>
<message-resources key="otherBundle" parameter="resources.OtherBundle"
null="false"/>

Both the bean:message messages get outputted as expected. This means
that the otherBundle resources are definitely registered with the
application.

However, the bean:write message does not get outputted as expected - I
get a ??? errors.foo.bar ??? message on the JSP

I've debugged the tag libraries and I think both bean:message and
bean:write call the org.apache.struts.taglib.TagUtils.message method
detailed below:

    public String message(
            PageContext pageContext,
            String bundle,
            String locale,
            String key,
            Object args[])
            throws JspException {

        MessageResources resources =
                retrieveMessageResources(pageContext, bundle, false);

        Locale userLocale = getUserLocale(pageContext, locale);
        String message = null;
        if (args == null) {
            message = resources.getMessage(userLocale, key);
        } else {
            message = resources.getMessage(userLocale, key, args);
        }
        if ((message == null) && log.isDebugEnabled()) {
            // log missing key to ease debugging
            log.debug(resources.getMessage("message.resources", key,
bundle, locale));
        }
        return message;
    }

When the bean:message tag is calling this method, the bundle parameter
has a value of 'otherBundle'.

However, when the bean:write tag calls this method the bundle parameter
is null - hence the ??? errors.foo.bar ??? message in my JSP.

Can someone offer advice on this issue? Do I have my JSP and
struts-config.xml configured correctly?

Any help would be greatly appreciated

Thanks

Sean

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message