1 16 17 package org.apache.struts.chain.servlet; 18 19 20 import java.util.Locale ; 21 import javax.servlet.http.HttpSession ; 22 import org.apache.commons.chain.Context; 23 import org.apache.commons.chain.web.servlet.ServletWebContext; 24 import org.apache.struts.Globals; 25 import org.apache.struts.chain.AbstractSelectLocale; 26 27 28 33 34 public class SelectLocale extends AbstractSelectLocale { 35 36 37 39 40 45 protected Locale getLocale(Context context) { 46 47 ServletWebContext swcontext = (ServletWebContext) context; 48 49 HttpSession session = swcontext.getRequest().getSession(); 51 Locale locale = (Locale ) session.getAttribute(Globals.LOCALE_KEY); 52 if (locale != null) { 53 return (locale); 54 } 55 56 locale = swcontext.getRequest().getLocale(); 58 if (locale == null) { 59 locale = Locale.getDefault(); 60 } 61 session.setAttribute(Globals.LOCALE_KEY, locale); 62 return (locale); 63 64 } 65 66 67 } 68 | Popular Tags |