struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject Re: how to get language from Locale??
Date Tue, 29 Apr 2003 12:45:48 GMT
If you're doing this from code that has a handle to a PageContext instance (e.g.
in a tag handler), use RequestUtils.retrieveUserLocale. Otherwise, here's
something that emulates what the retrieveUserLocale method is doing:

Locale locale = request.getLocale();
HttpSession session = request.getSession(false);
if (session != null) {
  Locale sessionLocale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
  if (sessionLocale != null) {
    locale = sessionLocale;
  }
}

Quoting Noureddine Bekrar <nbekrar@rennes.jouve.fr>:

> yes it's ok,
> 
> you can do that:
> String lg = ( (Locale) pageContext.getAttribute( Action.LOCALE_KEY,
> PageContext.REQUEST_SCOPE)).getLanguage();
> 
> 
> 
> 
> ----- Original Message -----
> From: "Dmitri Ilyin" <dmitri.ilyin@gmx.net>
> To: <struts-user@jakarta.apache.org>
> Sent: Tuesday, April 29, 2003 2:24 PM
> Subject: how to get language from Locale??
> 
> 
> > Hi,
> >
> > what is the simplest way to get language from Session Locale???
> >
> > I could get Locale Object from Session with the Key
> > "org.apache.struts.action.Action.LOCALE_KEY" and cast it and call
> > getLanguage().
> >
> > Are there any better way???
> >
> > regards
> >
> > Dmitri
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Mime
View raw message