struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "O'Shea, Sean" <Sean.O'>
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" %>
	<h3 class="red"><bean:message key="errors.header"
	<bean:message key="errors.subheader" bundle="otherBundle" />
		<html:messages id="error">
			<li><bean:write name="error"
bundle="otherBundle" /></li>

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

<message-resources parameter="resources.ApplicationResources"
<message-resources key="otherBundle" parameter="resources.OtherBundle"

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

However, the bean:write message does not get outputted as expected - I
get a ??? ??? 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 ??? ??? 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



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message