当前位置: 首页>>代码示例>>Java>>正文


Java Config.set方法代码示例

本文整理汇总了Java中javax.servlet.jsp.jstl.core.Config.set方法的典型用法代码示例。如果您正苦于以下问题:Java Config.set方法的具体用法?Java Config.set怎么用?Java Config.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.jsp.jstl.core.Config的用法示例。


在下文中一共展示了Config.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sessionCreated

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/** HttpSessionListener interface */
   @Override
   public void sessionCreated(HttpSessionEvent sessionEvent) {
if (sessionEvent == null) {
    return;
}
HttpSession session = sessionEvent.getSession();
session.setMaxInactiveInterval(SessionListener.timeout);

//set server default locale for STURTS and JSTL. This value should be overwrite
//LocaleFilter class. But this part code can cope with login.jsp Locale.
if (session != null) {
    String defaults[] = LanguageUtil.getDefaultLangCountry();
    Locale preferredLocale = new Locale(defaults[0] == null ? "" : defaults[0],
	    defaults[1] == null ? "" : defaults[1]);
    session.setAttribute(LocaleFilter.PREFERRED_LOCALE_KEY, preferredLocale);
    Config.set(session, Config.FMT_LOCALE, preferredLocale);
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:SessionListener.java

示例2: setTimeZone

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
private void setTimeZone(Context ctx, User user, HttpServletRequest request) {
    RhnTimeZone tz = null;
    if (user != null) {
        tz = user.getTimeZone();
        LOG.debug("Set timezone from the user.");
    }
    if (tz == null) {
        // Use the Appserver timezone if the User doesn't have one.
        String olsonName = TimeZone.getDefault().getID();
        if (LOG.isDebugEnabled()) {
            LOG.debug("olson name [" + olsonName + "]");
        }
        tz = UserManager.getTimeZone(olsonName);
        // if we're still null set it to a default
        if (tz == null) {
            tz = new RhnTimeZone();
            tz.setOlsonName(olsonName);

            LOG.debug("timezone still null");
        }
    }
    ctx.setTimezone(tz.getTimeZone());
    // Set the timezone on the request so that fmt:formatDate
    // can find it
    Config.set(request, Config.FMT_TIME_ZONE, tz.getTimeZone());
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:27,代码来源:LocalizedEnvironmentFilter.java

示例3: setOtherResourceBundles

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
    * Sets the Stripes error and field resource bundles in the request, if their names have been configured.
    */
@Override
protected void setOtherResourceBundles(HttpServletRequest request)
{
	Locale locale = request.getLocale();

       if (errorBundleName != null)
       {
           ResourceBundle errorBundle = getLocalizationBundleFactory().getErrorMessageBundle(locale);
           Config.set(request, errorBundleName, new LocalizationContext(errorBundle, locale));
           LOGGER.debug("Loaded Stripes error message bundle ", errorBundle, " as ", errorBundleName);
       }

       if (fieldBundleName != null)
       {
           ResourceBundle fieldBundle = getLocalizationBundleFactory().getFormFieldBundle(locale);
           Config.set(request, fieldBundleName, new LocalizationContext(fieldBundle, locale));
           LOGGER.debug("Loaded Stripes field name bundle ", fieldBundle, " as ", fieldBundleName);
       }
}
 
开发者ID:StripesFramework,项目名称:stripes-stuff,代码行数:23,代码来源:JstlBundleInterceptor.java

示例4: doEndTag

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
public int doEndTag() throws JspException {
    try {
        init();
        
        ValueMap valueMap = request.getResource().adaptTo(ValueMap.class);
        I18nResourceBundle bundle = new I18nResourceBundle(valueMap,
                getResourceBundle(getBaseName(), request));
        
        // make this resource bundle & i18n available as ValueMap for TEI
        pageContext.setAttribute(getMessagesName(),
                bundle.adaptTo(ValueMap.class), 
                PageContext.PAGE_SCOPE);
        pageContext.setAttribute(getI18nName(), 
                new I18n(bundle), 
                PageContext.PAGE_SCOPE);

        // make this resource bundle available for fmt functions
        Config.set(pageContext, "javax.servlet.jsp.jstl.fmt.localizationContext", new LocalizationContext(bundle, getLocale(request)), 1);
    } catch(Exception e) {
        LOG.error(e.getMessage());
        throw new JspException(e);
    }
    return EVAL_PAGE;
}
 
开发者ID:steeleforge,项目名称:ironsites,代码行数:25,代码来源:I18nHelperTag.java

示例5: exposeLocalizationContext

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
 * Exposes JSTL-specific request attributes specifying locale
 * and resource bundle for JSTL's formatting and message tags,
 * using Spring's locale and MessageSource.
 * @param request the current HTTP request
 * @param messageSource the MessageSource to expose,
 * typically the current ApplicationContext (may be {@code null})
 * @see #exposeLocalizationContext(RequestContext)
 */
public static void exposeLocalizationContext(HttpServletRequest request, MessageSource messageSource) {
	Locale jstlLocale = RequestContextUtils.getLocale(request);
	Config.set(request, Config.FMT_LOCALE, jstlLocale);
	TimeZone timeZone = RequestContextUtils.getTimeZone(request);
	if (timeZone != null) {
		Config.set(request, Config.FMT_TIME_ZONE, timeZone);
	}
	if (messageSource != null) {
		LocalizationContext jstlContext = new SpringLocalizationContext(messageSource, request);
		Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, jstlContext);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:JstlUtils.java

示例6: setLocale

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
 * Setta a session scope la locale passata con chiave di attributo coerente a JSTL
 * @param pLocale
 * @param pHttpSession
 */
public static void setLocale(Locale pLocale, HttpSession pHttpSession) {
	if (pHttpSession==null || pLocale==null) throw new JBrickException(JBrickException.FATAL);
	mLog.debug("ENTER setLocale(Session) con locale ",pLocale.toString());
	Config.set(pHttpSession, Config.FMT_LOCALE, pLocale);
	mLog.debug("FINISH setLocale(Session)");
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:12,代码来源:LocaleUtil.java

示例7: getBundle

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
@Override @Produces
public ResourceBundle getBundle(Locale locale) {
	Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, null);
	ResourceBundle customBundle = super.getBundle(locale);
	Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, "mamute-messages");
	ResourceBundle mamuteBundle = super.getBundle(locale);
	
	return new MamuteResourceBundle(customBundle, mamuteBundle);
}
 
开发者ID:caelum,项目名称:mamute,代码行数:10,代码来源:MamuteLocalization.java

示例8: doFilter

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
 * Ssets the locale context-wide based on a call to {@link JiveGlobals#getLocale()}.
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    final String pathInfo = ((HttpServletRequest)request).getPathInfo();

    if (pathInfo == null) {
        // Note, putting the locale in the application at this point is a little overkill
        // (ie, every user who hits this filter will do this). Eventually, it might make
        // sense to just set the locale in the user's session and if that's done we might
        // want to honor a preference to get the user's locale based on request headers.
        // For now, this is just a convenient place to set the locale globally.
        Config.set(context, Config.FMT_LOCALE, JiveGlobals.getLocale());
    }
    else {
        try {
            String[] parts = pathInfo.split("/");
            String pluginName = parts[1];
            ResourceBundle bundle = LocaleUtils.getPluginResourceBundle(pluginName);
            LocalizationContext ctx = new LocalizationContext(bundle, JiveGlobals.getLocale());
            Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, ctx);
        }
        catch (Exception e) {
            // Note, putting the locale in the application at this point is a little overkill
            // (ie, every user who hits this filter will do this). Eventually, it might make
            // sense to just set the locale in the user's session and if that's done we might
            // want to honor a preference to get the user's locale based on request headers.
            // For now, this is just a convenient place to set the locale globally.
            Config.set(context, Config.FMT_LOCALE, JiveGlobals.getLocale());
        }
    }
    // Move along:
    chain.doFilter(request, response);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:LocaleFilter.java

示例9: exposeLocalizationContext

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
 * Exposes JSTL-specific request attributes specifying locale
 * and resource bundle for JSTL's formatting and message tags,
 * using Spring's locale and MessageSource.
 * @param requestContext the context for the current HTTP request,
 * including the ApplicationContext to expose as MessageSource
 */
public static void exposeLocalizationContext(RequestContext requestContext) {
	Config.set(requestContext.getRequest(), Config.FMT_LOCALE, requestContext.getLocale());
	MessageSource messageSource = getJstlAwareMessageSource(
			requestContext.getServletContext(), requestContext.getMessageSource());
	LocalizationContext jstlContext = new SpringLocalizationContext(messageSource, requestContext.getRequest());
	Config.set(requestContext.getRequest(), Config.FMT_LOCALIZATION_CONTEXT, jstlContext);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:15,代码来源:JstlUtils.java

示例10: doFilter

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
 * Ssets the locale context-wide based on a call to {@link JiveGlobals#getLocale()}.
 */
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    final String pathInfo = ((HttpServletRequest)request).getPathInfo();

    if (pathInfo == null) {
        // Note, putting the locale in the application at this point is a little overkill
        // (ie, every user who hits this filter will do this). Eventually, it might make
        // sense to just set the locale in the user's session and if that's done we might
        // want to honor a preference to get the user's locale based on request headers.
        // For now, this is just a convenient place to set the locale globally.
        Config.set(context, Config.FMT_LOCALE, JiveGlobals.getLocale());
    }
    else {
        try {
            String[] parts = pathInfo.split("/");
            String pluginName = parts[1];
            ResourceBundle bundle = LocaleUtils.getPluginResourceBundle(pluginName);
            LocalizationContext ctx = new LocalizationContext(bundle, JiveGlobals.getLocale());
            Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, ctx);
        }
        catch (Exception e) {
            // Note, putting the locale in the application at this point is a little overkill
            // (ie, every user who hits this filter will do this). Eventually, it might make
            // sense to just set the locale in the user's session and if that's done we might
            // want to honor a preference to get the user's locale based on request headers.
            // For now, this is just a convenient place to set the locale globally.
            Config.set(context, Config.FMT_LOCALE, JiveGlobals.getLocale());
        }
    }
    // Move along:
    chain.doFilter(request, response);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:36,代码来源:LocaleFilter.java

示例11: changeLocale

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
@Path("/change-location/{lenguageName}/{country}")
public void changeLocale(String lenguageName , String country , Result result, HttpSession session , HttpServletRequest request ){
    Locale locale = new Locale( lenguageName , country );
    Config.set( session, Config.FMT_FALLBACK_LOCALE, locale);
    Config.set (session, Config.FMT_LOCALE, locale);
    redirectBack(result , request);
}
 
开发者ID:cejug,项目名称:hurraa,代码行数:8,代码来源:ChangeLocaleController.java

示例12: setMessageResourceBundle

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
    * Sets the message resource bundle in the request using the JSTL's mechanism.
    */
@Override
   protected void setMessageResourceBundle(HttpServletRequest request, ResourceBundle bundle)
{
	Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(bundle, request.getLocale()));
       LOGGER.debug("Enabled JSTL localization using: ", bundle);
       LOGGER.debug("Loaded resource bundle ", bundle, " as default bundle");
   }
 
开发者ID:StripesFramework,项目名称:stripes-stuff,代码行数:11,代码来源:JstlBundleInterceptor.java

示例13: createMainGenerator

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
@Before
public void createMainGenerator() {
	fr = new Locale("fr", "FR");
	en = new Locale("en", "US");
	
	session = new MockHttpSession();
	Config.set(session, Config.FMT_LOCALE, fr);
	
	request = new MockHttpServletRequest();
	request.setSession(session);
	Config.set(request, Config.FMT_LOCALE, en);
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:13,代码来源:JstlLocaleResolverTest.java

示例14: should_then_resolve_locale_from_session

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
@Test
public void should_then_resolve_locale_from_session(){
	Config.set(request, Config.FMT_LOCALE, null);
	
	JstlLocaleResolver localeResolver = new JstlLocaleResolver();
	Locale locale = localeResolver.resolveLocale(request);
	
	assertThat(locale).isEqualTo(fr);
}
 
开发者ID:dandelion,项目名称:dandelion-datatables,代码行数:10,代码来源:JstlLocaleResolverTest.java

示例15: doFilterInternal

import javax.servlet.jsp.jstl.core.Config; //导入方法依赖的package包/类
/**
 * This method looks for a "locale" request parameter. If it finds one, it sets it as the preferred locale
 * and also configures it to work with JSTL.
 * 
 * @param request the current request
 * @param response the current response
 * @param chain the chain
 * @throws IOException when something goes wrong
 * @throws ServletException when a communication failure happens
 */
@SuppressWarnings("unchecked")
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
                             FilterChain chain)
        throws IOException, ServletException {

    String locale = request.getParameter("locale");
    Locale preferredLocale = null;

    if (locale != null) {
        int indexOfUnderscore = locale.indexOf('_');
        if (indexOfUnderscore != -1) {
            String language = locale.substring(0, indexOfUnderscore);
            String country = locale.substring(indexOfUnderscore + 1);
            preferredLocale = new Locale(language, country);
        } else {
            preferredLocale = new Locale(locale);
        }
    }

    HttpSession session = request.getSession(false);

    if (session != null) {
        if (preferredLocale == null) {
            preferredLocale = (Locale) session.getAttribute(Constants.PREFERRED_LOCALE_KEY);
        } else {
            session.setAttribute(Constants.PREFERRED_LOCALE_KEY, preferredLocale);
            Config.set(session, Config.FMT_LOCALE, preferredLocale);
        }

        if (preferredLocale != null && !(request instanceof LocaleRequestWrapper)) {
            request = new LocaleRequestWrapper(request, preferredLocale);
            LocaleContextHolder.setLocale(preferredLocale);
        }
    }

    chain.doFilter(request, response);

    // Reset thread-bound LocaleContext.
    LocaleContextHolder.setLocaleContext(null);
}
 
开发者ID:SMVBE,项目名称:ldadmin,代码行数:51,代码来源:LocaleFilter.java


注:本文中的javax.servlet.jsp.jstl.core.Config.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。