01: package com.technoetic.xplanner.actions;
02:
03: import java.util.Locale;
04: import javax.servlet.http.HttpServletRequest;
05: import javax.servlet.http.HttpServletResponse;
06: import javax.servlet.http.HttpSession;
07:
08: import org.apache.commons.lang.StringUtils;
09: import org.apache.struts.Globals;
10: import org.apache.struts.action.Action;
11: import org.apache.struts.action.ActionForm;
12: import org.apache.struts.action.ActionForward;
13: import org.apache.struts.action.ActionMapping;
14:
15: /**
16: * User: Mateusz Prokopowicz
17: * Date: Aug 2, 2005
18: * Time: 12:29:23 PM
19: */
20: public class ChangeLocaleAction extends Action {
21: public ActionForward execute(ActionMapping mapping,
22: ActionForm form, HttpServletRequest request,
23: HttpServletResponse response) throws Exception {
24: String language = request.getParameter("language");
25: String returnto = request
26: .getParameter(EditObjectAction.RETURNTO_PARAM);
27: Locale locale;
28: if (!StringUtils.isEmpty(language)) {
29: locale = new Locale(language);
30: } else {
31: locale = Locale.getDefault();
32: }
33: HttpSession session = request.getSession();
34: session.setAttribute(Globals.LOCALE_KEY, locale);
35: if (StringUtils.isEmpty(returnto)) {
36: return mapping.findForward("view/projects");
37: } else {
38: return new ActionForward(returnto, true);
39: }
40: }
41: }
|