So are you suggesting that I pass the request object to my ActionForm
constructor when I create it in my action?

-----Original Message-----
From: Deadman, Hal [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 04, 2001 13:56
To: [EMAIL PROTECTED]
Subject: RE: How do I Internationalize ActionError parameter values?


Use the request argument to get the session and then get the locale out of
the session using getAttribute(Action.LOCALE_KEY). If you have a shared base
class for all of your forms (that extends ActionForm) it might make sense to
put a getLocale(request) method in there.

Hal

> -----Original Message-----
> From: Kyle Robinson [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 04, 2001 4:53 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: How do I Internationalize ActionError parameter values?
>
>
> Thanks Hal.  However, I need to get the locale in the
> validate() method of
> my ActionForm object.  Any thoughts?
>
> -----Original Message-----
> From: Deadman, Hal [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 04, 2001 13:24
> To: [EMAIL PROTECTED]
> Subject: RE: How do I Internationalize ActionError parameter values?
>
>
> Getting the locale object is easy. If you are in an Action
> perform method,
> just call:
>
> getLocale(request);
>
> If you are not in the Action class, you can do what that method does,
>
> Locale locale = (Locale) session.getAttribute(Action.LOCALE_KEY);
> if (locale == null)
>      locale = Locale.getDefault();
>
> -----Original Message-----
> From: Kyle Robinson [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 04, 2001 3:48 PM
> To: Struts (E-mail)
> Subject: How do I Internationalize ActionError parameter values?
>
>
> Hey,
>
> Looking through the archive I found a couple of notes about
> internationalizing the ActionError parameters.  I'm talking about the
> following:
>
> public ActionError(java.lang.String key,
>                    java.lang.Object value0,
>                    java.lang.Object value1)
> Construct an action error with the specified replacement values.
> Parameters:
> key - Message key for this error message
> value0 - First replacement value
> value1 - Second replacement value
>
> What I want to do is pass in keys from the properties file
> into the second
> and third parameter.  Specifically I want to pass in the
> prompt keys to
> display to the user the fields that are in error.
>
> One possible solution proposed was by Craig as follows:
>
> The java.text.MessageFormat class (which is how Struts is doing the
> substitution) does not support internationalizing the replacement
> parameters directly.  But how about doing this in two steps?
>
> * Look up the internationalized replacement value from
>   a MessageResources bundle
>
> * Use the returned String as the replacement value in the
>   ultimate message.
>
> However, I need to get the locale somehow.  It seems alot
> easier to just
> override ActionError to accept keys as parameters.  Has
> anyone overridden
> the ActionError class to accept "java.lang.String key"
> parameters instead of
> "java.lang.Object value0"?
> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111
> "Work joyfully and peacefully, knowing that right thoughts
> and right efforts
> inevitably bring about right results." - James Allen
>

Reply via email to