| 1 23 package org.mdarad.framework.util.struts; 24 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.struts.action.ActionMapping; 28 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 import java.util.List ; 32 import java.util.Locale ; 33 34 public class SwitchLocaleAction extends AbstractAction { 35 38 public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { 39 String localeString = httpServletRequest.getParameter("locale"); 40 41 if (!(localeString == null || "".equals(localeString))) { 42 Locale locale = new Locale (localeString); 43 org.dataisland.primitives.bean.LocalizationContext localizationContext = StrutsLocalizationUtils.getLocalizationContext(httpServletRequest); 44 List locales = localizationContext.getLocales(); 45 if (locales.contains(locale)) { 46 locales.remove(locale); 47 } 48 locales.add(0, locale); 49 } 50 51 org.mdarad.framework.util.struts.StrutsLocalizationUtils.processLocale(httpServletRequest, WEB_CONTEXT_LOCALIZATION_CONTEXT_KEY); 52 53 return forwardDisplay(actionMapping, actionForm, httpServletRequest, httpServletResponse); 54 } 55 } 56 | Popular Tags |