RE: Resource bundles and Struts taglibs

2006-08-23 Thread O'Shea, Sean
Hi Niall,

Thanks again for your help - your suggestion worked.

Sean 

-Original Message-
From: Niall Pemberton [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 23, 2006 11:03 AM
To: Struts Users Mailing List
Subject: Re: Resource bundles and Struts taglibs

On 8/23/06, O'Shea, Sean  wrote:
> 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" %>
> 
>  bundle="otherBundle"/>
> 
> 
> 
>  bundle="otherBundle" />
> 
> 
> 
> 
>
> I'm plugging my resources into my struts-config.xml like this:
>
>  null="false"/>
>  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

Its the  tag that is converting the keys in your error
messages into the text -  is just accessing the page scope
variable that the text has been stored under and writing it out. The
bundle attribute for  is for use with the "formatKey"
attribute.

You need to specify the bundle on the  tag:

  

   

Niall

> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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



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



Re: Resource bundles and Struts taglibs

2006-08-23 Thread Niall Pemberton

On 8/23/06, O'Shea, Sean  wrote:

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" %>











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




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


Its the  tag that is converting the keys in your error
messages into the text -  is just accessing the page scope
variable that the text has been stored under and writing it out. The
bundle attribute for  is for use with the "formatKey"
attribute.

You need to specify the bundle on the  tag:

 
   
  

Niall


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




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