@Override public boolean getLocale() { return config.getLocale(); }
/** * <p>Automatically select a <code>Locale</code> for the current user, if * requested. <strong>NOTE</strong> - configuring Locale selection will * trigger the creation of a new <code>HttpSession</code> if * necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processLocale(HttpServletRequest request, HttpServletResponse response) { // Are we configured to select the Locale automatically? if (!moduleConfig.getControllerConfig().getLocale()) { return; } // Has a Locale already been selected? HttpSession session = request.getSession(); if (session.getAttribute(Globals.LOCALE_KEY) != null) { return; } // Use the Locale returned by the servlet container (if any) Locale locale = request.getLocale(); if (locale != null) { if (log.isDebugEnabled()) { log.debug(" Setting user locale '" + locale + "'"); } session.setAttribute(Globals.LOCALE_KEY, locale); } }
/** * <p>Automatically select a <code>Locale</code> for the current user, if requested. * <strong>NOTE</strong> - configuring Locale selection will trigger * the creation of a new <code>HttpSession</code> if necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processLocale(HttpServletRequest request, HttpServletResponse response) { // Are we configured to select the Locale automatically? if (!moduleConfig.getControllerConfig().getLocale()) { return; } // Has a Locale already been selected? HttpSession session = request.getSession(); if (session.getAttribute(Globals.LOCALE_KEY) != null) { return; } // Use the Locale returned by the servlet container (if any) Locale locale = request.getLocale(); if (locale != null) { if (log.isDebugEnabled()) { log.debug(" Setting user locale '" + locale + "'"); } session.setAttribute(Globals.LOCALE_KEY, locale); } }
/** * <p>Select the <code>Locale</code> to be used for this request.</p> * * @param actionCtx The <code>Context</code> for the current request * @return <code>false</code> so that processing continues * @throws Exception if thrown by the Action class */ public boolean execute(ActionContext actionCtx) throws Exception { // Are we configured to select Locale automatically? LOG.trace("retrieve config..."); ModuleConfig moduleConfig = actionCtx.getModuleConfig(); if (!moduleConfig.getControllerConfig().getLocale()) { if (LOG.isDebugEnabled()) { LOG.debug("module is not configured for a specific locale; " + "nothing to do"); } return (false); } // Retrieve and cache appropriate Locale for this request Locale locale = getLocale(actionCtx); if (LOG.isDebugEnabled()) { LOG.debug("set context locale to " + locale); } actionCtx.setLocale(locale); return (false); }