Getting Messages in an Action from multiple bundles

2003-11-14 Thread Peter Sloots
Hi

I have multiple resources

message-resources parameter=resources.application/
message-resources key=config parameter=resources.config/

In jsp I can get the values by doing

bean:message key=aValue/
bean:message bundle=config key=anotherValue/

But how do I get the values from resources with the config key in an action?
Somewhere I read it's possible by doing:
MessageResources mr = (MessageResources)request.getAttribute(config);
But this is not working for me.

I tried a work around by using
org.apache.struts.taglib.bean.MessageTag mt = new 
org.apache.struts.taglib.bean.MessageTag();
mt.setBundle(config);
mt.setKey(anotherValue);
but how do I read the variable
mt.getValue(anotherValue); gives me null

ne1?




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



Getting Messages in an Action?

2003-09-16 Thread Carl-Eric Menzel

Hello,

is it possible to retrieve a message from the application resources
(like bean:message key=.../) inside an Action? How can I get to
the current localized messages?

Thanks
Carl-Eric


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



RE: Getting Messages in an Action?

2003-09-16 Thread Andrew Hill
Yes, you can call the getResources() method inside your action which will
return a MessageResources object that you can read the localised messages
from. Check the javadoc for details on the parameters.

-Original Message-
From: Carl-Eric Menzel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 16 September 2003 23:22
To: [EMAIL PROTECTED]
Subject: Getting Messages in an Action?



Hello,

is it possible to retrieve a message from the application resources
(like bean:message key=.../) inside an Action? How can I get to
the current localized messages?

Thanks
Carl-Eric


-
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: Getting Messages in an Action?

2003-09-16 Thread Andrew Kuzmin
MessageResources resources = getResources(request);
java.util.Locale locale = getLocale(request);
String yourString = resources.getMessage(locale, yourString);

--
Andrew Kuzmin
http://www.java201.com


- Original Message - 
From: Carl-Eric Menzel [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 6:21 PM
Subject: Getting Messages in an Action?


 
 Hello,
 
 is it possible to retrieve a message from the application resources
 (like bean:message key=.../) inside an Action? How can I get to
 the current localized messages?
 
 Thanks
 Carl-Eric
 
 
 -
 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: Getting Messages in an Action?

2003-09-16 Thread Adolfo Miguelez
and what about from an ExceptionHandler?


From: Andrew Kuzmin [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED],   
Carl-Eric Menzel [EMAIL PROTECTED]
Subject: Re: Getting Messages in an Action?
Date: Tue, 16 Sep 2003 18:29:39 +0300

MessageResources resources = getResources(request);
java.util.Locale locale = getLocale(request);
String yourString = resources.getMessage(locale, yourString);
--
Andrew Kuzmin
http://www.java201.com
- Original Message -
From: Carl-Eric Menzel [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 6:21 PM
Subject: Getting Messages in an Action?

 Hello,

 is it possible to retrieve a message from the application resources
 (like bean:message key=.../) inside an Action? How can I get to
 the current localized messages?

 Thanks
 Carl-Eric


 -
 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]
_
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus

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


Re: Getting Messages in an Action?

2003-09-16 Thread Andrew Kuzmin
org.apache.struts.action.ExceptionHandler:
snip
public ActionForward execute(Exception ex,
 ExceptionConfig ae,
 ActionMapping mapping,
 ActionForm formInstance,
 HttpServletRequest request,
 HttpServletResponse response)
/snip

MessageResources resources = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);

--
Andrew Kuzmin
http://www.java201.com


- Original Message -
From: Adolfo Miguelez [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 6:47 PM
Subject: Re: Getting Messages in an Action?


 and what about from an ExceptionHandler?


 From: Andrew Kuzmin [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED],
 Carl-Eric Menzel [EMAIL PROTECTED]
 Subject: Re: Getting Messages in an Action?
 Date: Tue, 16 Sep 2003 18:29:39 +0300
 
 MessageResources resources = getResources(request);
 java.util.Locale locale = getLocale(request);
 String yourString = resources.getMessage(locale, yourString);
 
 --
 Andrew Kuzmin
 http://www.java201.com
 
 
 - Original Message -
 From: Carl-Eric Menzel [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, September 16, 2003 6:21 PM
 Subject: Getting Messages in an Action?
 
 
  
   Hello,
  
   is it possible to retrieve a message from the application resources
   (like bean:message key=.../) inside an Action? How can I get to
   the current localized messages?
  
   Thanks
   Carl-Eric
  
  
   -
   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]
 

 _
 MSN 8 with e-mail virus protection service: 2 months FREE*
 http://join.msn.com/?page=features/virus


 -
 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[2]: Getting Messages in an Action?

2003-09-16 Thread Carl-Eric Menzel
 MessageResources resources = getResources(request);
 java.util.Locale locale = getLocale(request);
 String yourString = resources.getMessage(locale, yourString);

Duh. I should read the docs more carefully (and sleep more, probably).
Thank you!

Carl-Eric


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



Re: Getting Messages in an Action?

2003-09-16 Thread Adolfo Miguelez
Cheers Andrew,

I thought about it so thanks for your confirmation. However, I have an just 
a doubt. AFAIK, in Struts 1.1, ApplicationResources can be spread in 
different bundles. How do you choose which one is the targeted bundle in 
order to find the key?

Sorry if I am missunderstanding something.

Adolfo.

From: Andrew Kuzmin [EMAIL PROTECTED]
Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: Re: Getting Messages in an Action?
Date: Tue, 16 Sep 2003 19:12:38 +0300
org.apache.struts.action.ExceptionHandler:
snip
public ActionForward execute(Exception ex,
 ExceptionConfig ae,
 ActionMapping mapping,
 ActionForm formInstance,
 HttpServletRequest request,
 HttpServletResponse response)
/snip
MessageResources resources = (MessageResources)
request.getAttribute(Globals.MESSAGES_KEY);
--
Andrew Kuzmin
http://www.java201.com
- Original Message -
From: Adolfo Miguelez [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 6:47 PM
Subject: Re: Getting Messages in an Action?
 and what about from an ExceptionHandler?


 From: Andrew Kuzmin [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED],
 Carl-Eric Menzel [EMAIL PROTECTED]
 Subject: Re: Getting Messages in an Action?
 Date: Tue, 16 Sep 2003 18:29:39 +0300
 
 MessageResources resources = getResources(request);
 java.util.Locale locale = getLocale(request);
 String yourString = resources.getMessage(locale, yourString);
 
 --
 Andrew Kuzmin
 http://www.java201.com
 
 
 - Original Message -
 From: Carl-Eric Menzel [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, September 16, 2003 6:21 PM
 Subject: Getting Messages in an Action?
 
 
  
   Hello,
  
   is it possible to retrieve a message from the application resources
   (like bean:message key=.../) inside an Action? How can I get to
   the current localized messages?
  
   Thanks
   Carl-Eric
  
  
   
-
   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]
 

 _
 MSN 8 with e-mail virus protection service: 2 months FREE*
 http://join.msn.com/?page=features/virus


 -
 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]
_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

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