List of usage examples for javax.servlet.http HttpServletRequest getLocale
public Locale getLocale();
Locale
that the client will accept content in, based on the Accept-Language header. From source file:mx.um.edu.medicina.camposClinicos.webapp.PlazaFormController.java
@RequestMapping(method = RequestMethod.POST) public String onSubmit(Plaza plaza, BindingResult errors, HttpServletRequest request, HttpServletResponse response) throws Exception { if (request.getParameter("cancel") != null) { return getCancelView(); }//from w w w . j a v a2s . c om if (validator != null) { // validator is null during testing validator.validate(plaza, errors); if (errors.hasErrors() && request.getParameter("delete") == null) { // don't validate when deleting return "plazaform"; } } log.debug("entering 'onSubmit' method..."); boolean isNew = (plaza.getId() == null); String success = getSuccessView(); Locale locale = request.getLocale(); if (request.getParameter("delete") != null) { plazaManager.remove(plaza.getId()); saveMessage(request, getText("plaza.deleted", locale)); } else { plazaManager.save(plaza); String key = (isNew) ? "plaza.added" : "plaza.updated"; saveMessage(request, getText(key, locale)); if (!isNew) { success = "redirect:camposClinicos/plazaform?id=" + plaza.getId(); } } return success; }
From source file:fr.paris.lutece.plugins.mylutece.web.MyLuteceApp.java
/** * This method builds a XPage object corresponding to the request * @param request The HTTP request//from w w w. j av a 2 s. co m * @param nMode The mode * @param plugin The plugin object which belongs the App * @return The XPage object containing the page content */ public XPage getPage(HttpServletRequest request, int nMode, Plugin plugin) { XPage page = new XPage(); String strAction = request.getParameter(PARAMETER_ACTION); _locale = request.getLocale(); if (StringUtils.equals(strAction, ACTION_CREATE_ACCOUNT)) { return getCreateAccountPage(page, request); } else if (StringUtils.equals(strAction, ACTION_VIEW_ACCOUNT)) { return getViewAccountPage(page); } else if (StringUtils.equals(strAction, ACTION_LOST_PASSWORD)) { return getLostPasswordPage(page); } else if (StringUtils.equals(strAction, ACTION_LOST_LOGIN)) { return getLostLoginPage(page); } return getLoginPage(page, request); }
From source file:architecture.ee.web.servlet.ViewRendererServlet.java
protected View resolvingView(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) { /**// w ww .j av a2 s . c o m * ? VIEW ContentType ? ?? ? . */ View view = (View) httpservletrequest.getAttribute(WebApplicatioinConstants.VIEW_ATTRIBUTE); if (view == null) { try { String viewName = translator.getViewName(httpservletrequest); ViewResolver viewresolver = getViewResolver(viewResolverName); view = viewresolver.resolveViewName(viewName, httpservletrequest.getLocale()); } catch (Exception exception) { log.error(exception); } if (view != null && view instanceof AbstractView) { OutputFormat format = ServletUtils.getOutputFormat(httpservletrequest, httpservletresponse); if (log.isDebugEnabled()) log.debug("architecture.ee.web.community.content: " + format); if (format == OutputFormat.XML) { httpservletresponse.setContentType(null); ((AbstractView) view).setContentType("text/xml;charset=UTF-8"); } else if (format == OutputFormat.HTML) { httpservletresponse.setContentType(null); ((AbstractView) view).setContentType("text/html;charset=UTF-8"); } } } if (log.isDebugEnabled()) { log.debug( "response architecture.ee.web.community.content type: " + httpservletresponse.getContentType()); log.debug("architecture.ee.web.community.content type : " + view.getContentType()); } return view; }
From source file:es.pode.administracion.presentacion.planificador.listarTareasPendientes.TareasPendientesControllerImpl.java
public final void obtenerTareasPendientes(ActionMapping mapping, ObtenerTareasPendientesForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from w w w . j ava2 s .co m TareaVO[] tareas = this.getSrvPlanificadorService().obtenerTareasPendientes(); TareaDate[] tareasDate = null; if (tareas != null) { tareasDate = cambiarFormatoTareas(tareas, request.getLocale()); tareasDate = ordenaAscendente(tareasDate, form.getTareaModificada()); ((ListarTareasPendientesFormImpl) form).setTareasPendientesAsArray(tareasDate); } } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:alpha.portal.webapp.controller.CardAssignFormController.java
/** * Adds the selected user to the case's participants and sets him as * Contributor for the card. Also returns to caseform on cancel. * // w ww . j a va 2 s. co m * @param request * the request * @param response * the response * @throws Exception * the exception */ @RequestMapping(method = RequestMethod.POST) public void onSubmit(final HttpServletRequest request, final HttpServletResponse response) throws Exception { final String caseId = request.getParameter("case"); final String cardId = request.getParameter("card"); final String userId = request.getParameter("user"); if (request.getParameter("cancel") != null) { this.returnToCase(response, caseId, cardId); return; } if (StringUtils.isBlank(userId)) { this.saveError(request, this.getText("cardassign.noUser", request.getLocale())); this.returnToCase(response, caseId, cardId); return; } Long userIdLong = null; try { userIdLong = Long.parseLong(userId); } catch (final NumberFormatException e) { this.saveError(request, "cardassign.invalidUser"); this.returnToCase(response, caseId, cardId); return; } if (userIdLong == null) { this.saveMessage(request, this.getText("cardassign.invalidUser", request.getLocale())); this.returnToCase(response, caseId, cardId); return; } final AlphaCard card = this.cardManager.get(new AlphaCardIdentifier(caseId, cardId)); UserExtension ue = null; try { ue = this.userExtensionManager.get(userIdLong); } catch (final DataAccessException e) { } if (ue == null) { try { final User u = this.getUserManager().get(userIdLong); ue = new UserExtension(u); ue = this.userExtensionManager.save(ue); } catch (final DataAccessException e) { this.saveError(request, "cardassign.invalidUser"); this.returnToCase(response, caseId, cardId); return; } } ContributorRequest contrRequest = new ContributorRequest( this.getUserManager().getUserByUsername(request.getRemoteUser()), this.getUserManager().get(userIdLong), card); contrRequest = this.contrReqManager.save(contrRequest); response.sendRedirect("caseform?caseId=" + caseId + "&activeCardId=" + cardId); }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Returns the 404 Error page//from www .ja v a 2s . c o m * @param request The HTTP request * @return The page */ public String getError404Page(HttpServletRequest request) { HashMap<String, Object> model = new HashMap<String, Object>(); fillPageModel(request, model); model.put(Markers.PAGE_TITLE, I18nService.getLocalizedString(PROPERTY_PAGE_TITLE_ERROR404, request.getLocale())); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_PAGE_ERROR404, request.getLocale(), model); return template.getHtml(); }
From source file:fr.paris.lutece.portal.service.admin.AdminUserService.java
/** * Get the locale for the current request * @param request The HTTP request//from ww w . j ava 2 s . c o m * @return the locale to use with this request */ public static Locale getLocale(HttpServletRequest request) { Locale locale; AdminUser user = getAdminUser(request); if (user != null) { // Take the locale of the current user if exists locale = user.getLocale(); } else { // TODO : Add cookie search // Take the locale of the browser locale = request.getLocale(); } return locale; }
From source file:eu.eidas.node.connector.ConnectorExceptionHandlerServlet.java
private void prepareErrorMessage(AbstractEIDASException exception, HttpServletRequest request) { if (exception.getMessage() == null) { LOG.info("BUSINESS EXCEPTION : An error occurred on EidasNode! Couldn't get Exception message."); } else {/* ww w .j a v a 2 s .c om*/ if (StringUtils.isBlank(exception.getSamlTokenFail())) { ResourceBundleMessageSource msgResource = (ResourceBundleMessageSource) getApplicationContext() .getBean(NodeBeanNames.SYSADMIN_MESSAGE_RESOURCES.toString()); final String errorMessage = msgResource.getMessage(exception.getErrorMessage(), new Object[] { exception.getErrorCode() }, request.getLocale()); exception.setErrorMessage(errorMessage); EidasNodeErrorUtil.prepareSamlResponseFail(request, exception, EidasNodeErrorUtil.ErrorSource.CONNECTOR); LOG.info("BUSINESS EXCEPTION : ", errorMessage); } else { LOG.info("BUSINESS EXCEPTION : ", exception.getMessage()); } } }
From source file:fr.paris.lutece.portal.web.PortalJspBean.java
/** * Returns the 500 Error page/* w ww. j av a 2 s. c om*/ * @param request The HTTP request * @param strCause The message * @return The page */ public String getError500Page(HttpServletRequest request, String strCause) { HashMap<String, Object> model = new HashMap<String, Object>(); fillPageModel(request, model); model.put(Markers.PAGE_TITLE, I18nService.getLocalizedString(PROPERTY_PAGE_TITLE_ERROR500, request.getLocale())); model.put(MARK_ERROR_CAUSE, strCause); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_PAGE_ERROR500, request.getLocale(), model); return template.getHtml(); }
From source file:net.naijatek.myalumni.framework.struts.MyAlumniExtendedTilesRequestProcessor.java
/** * Ensures the user locale is identified and stored in the session as * appropriate./*from w ww. ja v a2 s . c o m*/ * * @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; } // Get the Locale (if any) that is stored in the user's session HttpSession session = request.getSession(); Locale sessionLocale = (Locale) session.getAttribute(Globals.LOCALE_KEY); // Get the user's preferred Locale from the request Locale requestLocale = request.getLocale(); // If there was never a Locale in the session or it has changed, set it if (sessionLocale == null || (sessionLocale != requestLocale)) { if (logger.isDebugEnabled()) { logger.debug(" Setting user locale '" + requestLocale + "'"); } // Set the new Locale into the user's session session.setAttribute(Globals.LOCALE_KEY, requestLocale); session.setAttribute("localeKey", requestLocale.getLanguage()); // for // displaytag } }