List of usage examples for javax.servlet.jsp.jstl.core Config get
public static Object get(ServletContext context, String name)
From source file:com.jslsolucoes.tagria.lib.util.TagUtil.java
public static Locale locale(JspContext jspContext) { HttpSession httpSession = ((PageContext) jspContext).getSession(); Locale locale = Locale.forLanguageTag(getInitParam(TagriaConfigParameter.LOCALE)); if (Config.get(httpSession, Config.FMT_LOCALE) != null) { locale = (Locale) Config.get(httpSession, Config.FMT_LOCALE); }/*from ww w.java 2 s . com*/ return locale; }
From source file:org.openmrs.contrib.metadatarepository.webapp.filter.LocaleFilterTest.java
public void testJstlLocaleIsSet() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("locale", "es"); MockHttpServletResponse response = new MockHttpServletResponse(); request.setSession(new MockHttpSession(null)); filter.doFilter(request, response, new MockFilterChain()); assertNotNull(Config.get(request.getSession(), Config.FMT_LOCALE)); }
From source file:alpha.portal.webapp.filter.LocaleFilterTest.java
/** * Test jstl locale is set./*from w w w. ja v a2 s .co m*/ * * @throws Exception * the exception */ public void testJstlLocaleIsSet() throws Exception { final MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("locale", "es"); final MockHttpServletResponse response = new MockHttpServletResponse(); request.setSession(new MockHttpSession(null)); this.filter.doFilter(request, response, new MockFilterChain()); Assert.assertNotNull(Config.get(request.getSession(), Config.FMT_LOCALE)); }
From source file:opa.filter.LoadResourceBundle.java
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpSession session = request.getSession(); DatabaseResourceBundle bundle = null; InitiativeSetup setup = (InitiativeSetup) session.getAttribute("initiativeSetup"); LocalizationContext context = (LocalizationContext) Config.get(session, Config.FMT_LOCALIZATION_CONTEXT); if (context != null) bundle = (DatabaseResourceBundle) context.getResourceBundle(); if (setup == null || setup.getLang_id() == null) { throw new ServletException( "Could not get language from InitiativeSetup object in application context."); }//from w ww . j a va 2 s . c om if (bundle == null || !bundle.getLangId().equals(setup.getLang_id())) { if (bundle != null) { bundle.destroy(); bundle = null; } bundle = new DatabaseResourceBundle(jdbcJndi, setup.getLang_id()); bundle.init(); /* * set the localization context of the session for jsp to process */ Config.set(session, Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(bundle, null)); log.info("setting language for current user to: " + bundle.getLangId()); } fc.doFilter(req, res); }
From source file:org.displaytag.localization.I18nJstlAdapter.java
/** * @see LocaleResolver#resolveLocale(HttpServletRequest) */// ww w . j a v a 2 s . c o m public Locale resolveLocale(HttpServletRequest request) { Locale locale = (Locale) Config.get(request.getSession(), Config.FMT_LOCALE); if (locale == null) { locale = request.getLocale(); } return locale; }
From source file:org.dspace.app.webui.util.UIUtil.java
/** * Get the Locale for a session according to the user's language selection or language preferences. * Order of selection/* w w w. j ava2s. c o m*/ * - language selected via UI * - language as set by application * - language browser default * * @param request * the request Object * @return supportedLocale * Locale supported by this DSpace Instance for this request */ public static Locale getSessionLocale(HttpServletRequest request) { String paramLocale = request.getParameter("locale"); Locale sessionLocale = null; Locale supportedLocale = null; if (!StringUtils.isEmpty(paramLocale)) { /* get session locale according to user selection */ sessionLocale = new Locale(paramLocale); } if (sessionLocale == null) { /* get session locale set by application */ HttpSession session = request.getSession(); sessionLocale = (Locale) Config.get(session, Config.FMT_LOCALE); } /* * if session not set by selection or application then default browser * locale */ if (sessionLocale == null) { sessionLocale = request.getLocale(); } if (sessionLocale == null) { sessionLocale = I18nUtil.DEFAULTLOCALE; } supportedLocale = I18nUtil.getSupportedLocale(sessionLocale); return supportedLocale; }