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:es.pode.administracion.presentacion.planificador.eliminarTarea.EliminarTareasControllerImpl.java
public void eliminarTareasAdm(ActionMapping mapping, EliminarTareasAdmForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { TrabajoVO[] trabajos = null;/*w w w .j a va 2s. c o m*/ Boolean resultado; String resultadoString = null; String mensaje = null; //String listaTrabajo = request.getParameter("listaTrabajo"); String[] nombresTrabajoArray = form.getListaTrabajoPlana().split("#"); ResourceBundle ficheroRecursos = null; try { Locale locale = request.getLocale(); ficheroRecursos = this.getFicheroRecursos(locale); trabajos = new TrabajoVO[nombresTrabajoArray.length]; for (int i = 0; i < nombresTrabajoArray.length; i++) { trabajos[i] = new TrabajoVO(); trabajos[i].setTrabajo(nombresTrabajoArray[i]); } resultado = this.getSrvPlanificadorService().eliminarTareasAdm(trabajos); if (resultado.booleanValue() == true) { mensaje = ficheroRecursos.getString("eliminarTareasPendientes.tareasEliminadasOk"); resultadoString = ficheroRecursos.getString("tareas.OK"); } else if (resultado.booleanValue() == false) { mensaje = ficheroRecursos.getString("eliminarTareasPendientes.tareasEliminadasError"); resultadoString = ficheroRecursos.getString("tareas.ERROR"); } form.setDescripcionBaja(mensaje); form.setResultado(resultadoString); } catch (Exception e) { log.error("Error: " + e); throw new ValidatorException("{tareas.error}"); } }
From source file:org.jrecruiter.web.controller.BaseFormController.java
/** * Set up a custom property editor for converting form inputs to real objects * @param request the current request/*from ww w .j ava2 s. c o m*/ * @param binder the data binder */ @InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) { binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true)); binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, null, true)); binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); SimpleDateFormat dateFormat = new SimpleDateFormat(getText("date.format", request.getLocale())); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true)); }
From source file:com.aurel.track.user.ResetPasswordAction.java
/** * Processes the confirmation link for newly registered users. * @return//from w w w.j a va2 s .co m */ public String confirm() { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); Locale locale = request.getLocale(); if (locale == null) { locale = Locale.getDefault(); } LogoffBL.doLogoff(session, httpSession, locale); TPersonBean personBean = PersonBL.loadByForgotPasswordToken(ctk); boolean userFound = false; if (personBean != null && personBean.getTokenExpDate().getTime() > new Date().getTime()) { this.getSession().put("CUSER", personBean.getLoginName()); String prefLocale = personBean.getPrefLocale(); if (prefLocale != null) { locale = LocaleHandler.getLocaleFromString(prefLocale); } hasInitData = true; StringBuilder sb = new StringBuilder(); sb.append("{"); JSONUtility.appendStringValue(sb, "token", ctk); JSONUtility.appendStringValue(sb, "loginName", personBean.getLoginName(), true); sb.append("}"); initData = sb.toString(); userFound = true; } httpSession.setAttribute("localizationJSON", LocalizeJSON.encodeLocalization(locale)); String extJSLocale = LocaleHandler.getExistingExtJSLocale(locale); httpSession.setAttribute("EXTJSLOCALE", extJSLocale); if (userFound) { layoutCls = "com.trackplus.layout.ResetPasswordLayout"; pageTitle = "logon.resetPassword.title"; return "resetPassword"; } else { layoutCls = "com.trackplus.layout.ResetPasswordExpiredLayout"; pageTitle = "logon.register.expired.title"; return "expired"; } }
From source file:com.webapp.tags.MainNav.java
public void doTag() throws JspException, IOException { JspWriter out = getJspContext().getOut(); HttpServletRequest request = (HttpServletRequest) ((PageContext) getJspContext()).getRequest(); String contextPath = request.getContextPath(); Locale locale = request.getLocale(); // Retrieve the login for this request Login login = WebApp.getLogin(request); StringBuffer content = new StringBuffer(); content.append(// ww w .ja v a 2s . c om "<nav class=\"navbar navbar-default navbar-static-top\" role=\"navigation\" style=\"margin-bottom: 0\">\r\n"); content.append(navHeader(contextPath, locale, login)); content.append(navTopLinks(contextPath, locale, login)); content.append(navSidebar(contextPath, locale, login)); content.append("\t\t</nav>\r\n"); content.append("\t\t<!-- / Navigation -->\r\n"); out.println(content.toString()); }
From source file:fr.paris.lutece.portal.service.cache.PathCacheService.java
@Override public String getKey(String strXPageName, int nMode, String strTitlesUrls, HttpServletRequest request) { if (!isCacheEnable()) { return null; }// w w w .j a v a 2 s .c om StringBuilder builder = new StringBuilder(); builder.append("[XPageName:").append(strXPageName).append(']'); builder.append("[mode:").append(nMode).append(']'); if (strTitlesUrls != null) { builder.append("[titleUrls:").append(strTitlesUrls).append(']'); } if (request != null) { builder.append("[locale:").append(request.getLocale()).append(']'); String strPageId = request.getParameter(Parameters.PAGE_ID); if (StringUtils.isNotBlank(strPageId)) { builder.append('[').append(Parameters.PAGE_ID).append(':').append(strPageId).append(']'); } String strPortletId = request.getParameter(Parameters.PORTLET_ID); if (StringUtils.isNotBlank(strPortletId)) { builder.append('[').append(Parameters.PORTLET_ID).append(':').append(strPortletId).append(']'); } } return builder.toString(); }
From source file:com.aurel.track.admin.user.profile.ProfileAction.java
/** * Processes the confirmation link for newly registered users. * @return/* www.ja v a2 s . co m*/ */ public String confirm() { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); locale = request.getLocale(); if (locale == null) { locale = Locale.getDefault(); } LogoffBL.doLogoff(session, httpSession, locale); boolean personFound = false; TPersonBean personBean = PersonBL.loadByTokenPasswd(confirmToken); if (personBean != null) { //&& personBean.getTokenExpDate().getTime() > new Date().getTime()) { String prefLocale = personBean.getPrefLocale(); if (prefLocale != null) { locale = LocaleHandler.getLocaleFromString(prefLocale); } personBean.setDisabled(false); personBean.setTokenExpDate(null); personBean.setTokenPasswd(null); PersonBL.save(personBean); this.getSession().put("CUSER", personBean.getLoginName()); personFound = true; locale = personBean.getLocale(); } httpSession.setAttribute("localizationJSON", LocalizeJSON.encodeLocalization(locale)); String extJSLocale = LocaleHandler.getExistingExtJSLocale(locale); httpSession.setAttribute("EXTJSLOCALE", extJSLocale); StringBuilder sb = LogoffBL.createInitData(httpSession, false, request, false, null, locale); initData = sb.toString(); if (personFound) { return "confirmed"; } else { return "expired"; } }
From source file:fr.paris.lutece.plugins.extend.modules.rating.web.type.VoteTypeJspBean.java
/** * Gets the manage vote types./*from ww w . java 2s . c om*/ * * @param request the request * @param response the response * @return the manage vote types * @throws AccessDeniedException the access denied exception */ public IPluginActionResult getManageVoteTypes(HttpServletRequest request, HttpServletResponse response) throws AccessDeniedException { setPageTitleProperty(RatingConstants.PROPERTY_MANAGE_VOTE_TYPES_PAGE_TITLE); Map<String, Object> model = new HashMap<String, Object>(); model.put(RatingConstants.MARK_LIST_VOTE_TYPES, _voteService.findAll(false)); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_MANAGE_VOTE_TYPES, request.getLocale(), model); IPluginActionResult result = new DefaultPluginActionResult(); result.setHtmlContent(getAdminPage(template.getHtml())); return result; }
From source file:org.jamwiki.taglib.PaginationTag.java
/** * */// w ww .ja v a 2 s . c o m private StringBuffer nextPage(Pagination pagination, String baseUrl, int count, boolean previous) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); StringBuffer output = new StringBuffer(); try { Object[] objects = new Object[1]; objects[0] = new Integer(pagination.getNumResults()); if (pagination.getOffset() == 0 && previous) { output.append(Utilities.formatMessage("common.pagination.previous", request.getLocale(), objects)); return output; } if (pagination.getNumResults() != count && !previous) { output.append(Utilities.formatMessage("common.pagination.next", request.getLocale(), objects)); return output; } output.append("<a href=\""); String virtualWiki = WikiUtil.getVirtualWikiFromRequest(request); WikiLink wikiLink = LinkUtil.parseWikiLink(baseUrl); int offset = pagination.getOffset() + pagination.getNumResults(); if (previous) { offset = pagination.getOffset() - pagination.getNumResults(); if (offset < 0) { offset = 0; } } String query = LinkUtil.appendQueryParam(wikiLink.getQuery(), "num", Integer.toString(pagination.getNumResults())); query += "&offset=" + offset; wikiLink.setQuery(query); output.append(LinkUtil.buildInternalLinkUrl(request.getContextPath(), virtualWiki, wikiLink)); output.append("\">"); if (previous) { output.append(Utilities.formatMessage("common.pagination.previous", request.getLocale(), objects)); } else { output.append(Utilities.formatMessage("common.pagination.next", request.getLocale(), objects)); } output.append("</a>"); } catch (Exception e) { logger.warning("Failure while building pagination element", e); } return output; }
From source file:com.jaspersoft.jasperserver.war.JSSessionLocaleResolver.java
public Locale resolveLocale(HttpServletRequest request) { String sessionAttribute = JasperServerConstImpl.getUserLocaleSessionAttr(); Locale locale = null;/*from ww w .jav a 2 s. c om*/ try { locale = (Locale) request.getSession().getAttribute(sessionAttribute); } catch (Exception e) { } finally { if (locale == null) { //Try to get locale from cookies for login page, see bug #30500 locale = getLocaleFromCookies(request); } if (locale == null) { locale = request.getLocale(); } } return locale; }
From source file:fr.paris.lutece.plugins.federatedatabasefranceconnect.web.FederateFranceConnectApp.java
/** * Build the Login page/*from w w w .ja v a 2 s .com*/ * @param request The HTTP request * @return The XPage object containing the page content */ @View(value = VIEW_HOME, defaultView = true) public XPage getHomePage(HttpServletRequest request) { Map<String, Object> model = getModel(); LuteceUser user = SecurityService.getInstance().getRegisteredUser(request); if (user != null) { model.put(MARK_USER, user); model.put(MARK_FEDERATE_LINK, FederateLinkService.getInstance().getFederateLinkByLuteceUserName(user.getName())); } return getXPage(TEMPLATE_HOME, request.getLocale(), model); }