Examples of LocalizationContext


Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

    //*********************************************************************
    // Tag logic

    public int doEndTag() throws JspException {
  LocalizationContext locCtxt =
      BundleSupport.getLocalizationContext(pageContext, basename);

  if (var != null) {
      pageContext.setAttribute(var, locCtxt, scope);
  } else {
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

    }

    public int doEndTag() throws JspException {

        String key = null;
  LocalizationContext locCtxt = null;

        // determine the message key by...
        if (keySpecified) {
      // ... reading 'key' attribute
      key = keyAttrValue;
  } else {
      // ... retrieving and trimming our body
      if (bodyContent != null && bodyContent.getString() != null)
          key = bodyContent.getString().trim();
  }

  if ((key == null) || key.equals("")) {
      try {
    pageContext.getOut().print("??????");
      } catch (IOException ioe) {
    throw new JspTagException(ioe.toString(), ioe);
      }
      return EVAL_PAGE;
  }

  String prefix = null;
  if (!bundleSpecified) {
      Tag t = findAncestorWithClass(this, BundleSupport.class);
      if (t != null) {
    // use resource bundle from parent <bundle> tag
    BundleSupport parent = (BundleSupport) t;
    locCtxt = parent.getLocalizationContext();
    prefix = parent.getPrefix();
      } else {
    locCtxt = BundleSupport.getLocalizationContext(pageContext);
      }
  } else {
      // localization context taken from 'bundle' attribute
      locCtxt = bundleAttrValue;
      if (locCtxt.getLocale() != null) {
    SetLocaleSupport.setResponseLocale(pageContext,
               locCtxt.getLocale());
      }
  }
       
   String message = UNDEFINED_KEY + key + UNDEFINED_KEY;
  if (locCtxt != null) {
      ResourceBundle bundle = locCtxt.getResourceBundle();
      if (bundle != null) {
    try {
        // prepend 'prefix' attribute from parent bundle
        if (prefix != null)
      key = prefix + key;
        message = bundle.getString(key);
        // Perform parametric replacement if required
        if (!params.isEmpty()) {
      Object[] messageArgs = params.toArray();
      MessageFormat formatter = new MessageFormat(""); // empty pattern, default Locale
      if (locCtxt.getLocale() != null) {
          formatter.setLocale(locCtxt.getLocale());
      } else {
                            // For consistency with the <fmt:formatXXX> actions,
                            // we try to get a locale that matches the user's preferences
                            // as well as the locales supported by 'date' and 'number'.
                            //System.out.println("LOCALE-LESS LOCCTXT: GETTING FORMATTING LOCALE");
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

          bundleString = bundle.getString(key);
      } catch (Exception e) {
      }
    }
    else if (lc instanceof String) {
      LocalizationContext loc = getBundle((String) lc);
      locale = loc.getLocale();

      ResourceBundle bundle = loc.getResourceBundle();

      try {
        if (bundle != null)
          bundleString = bundle.getString(key);
      } catch (Exception e) {
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

   * Returns the localized message appropriate for the current context.
   */
  public LocalizationContext getBundle(String name)
  {
    Object localeObj = Config.find(this, Config.FMT_LOCALE);
    LocalizationContext bundle = null;
    BundleManager manager = getBundleManager();

    if (localeObj instanceof Locale) {
      Locale locale = (Locale) localeObj;

View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

   */
  private Locale getLocaleImpl()
  {
    Object localeObj = Config.find(this, Config.FMT_LOCALIZATION_CONTEXT);

    LocalizationContext lc;
    Locale locale = null;

    if (localeObj instanceof LocalizationContext) {
      lc = (LocalizationContext) localeObj;

      locale = lc.getLocale();

      if (locale != null)
        return locale;
    }

    localeObj = Config.find(this, Config.FMT_LOCALE);

      if (localeObj instanceof Locale)
        return (Locale) localeObj;
    else if (localeObj instanceof String)
      return getLocale((String) localeObj, null);

    lc = (LocalizationContext) getAttribute("caucho.bundle");

    if (lc != null)
      locale = lc.getLocale();

    if (locale != null)
      return locale;

    String acceptLanguage = getCauchoRequest().getHeader("Accept-Language");
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

   * Returns the named ResourceBundle.
   */
  public LocalizationContext getBundle(String name, String cacheKey,
                                       Enumeration<Locale> locales)
  {
    LocalizationContext cachedValue = _bundleCache.get(cacheKey);

    if (cachedValue != null)
      return cachedValue == NULL_BUNDLE ? null : cachedValue;

    while (locales.hasMoreElements()) {
      Locale locale = locales.nextElement();

      LocalizationContext bundle = getBundle(name, locale);

      if (bundle != null) {
        _bundleCache.put(cacheKey, bundle);
        return bundle;
      }
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

    String cacheName = (name
                        + '_' + locale.getLanguage()
                        + '_' + locale.getCountry()
                        + '_' + locale.getVariant());

    LocalizationContext context;

    context = _bundleCache.get(cacheName);

    if (context != null)
      return context != NULL_BUNDLE ? context : null;

    ResourceBundle parent = getBaseBundle(name);

    ResourceBundle bundle = getBaseBundle(name
                                          + '_' + locale.getLanguage());

    ResourceBundle matchBundle = null;

   
    if (bundle != null) {
      if (parent != null) {
        try {
          _bundleSetParentMethod.invoke(bundle, parent);
        }
        catch (Exception e) {
          log.log(Level.WARNING, e.getMessage(), e);
        }
      }
     
      parent = bundle;
      matchBundle = bundle;
    }

    bundle = getBaseBundle(name
                           + '_' + locale.getLanguage()
                           + '_' + locale.getCountry());
   
    if (bundle != null) {
      if (parent != null) {
        try {
          _bundleSetParentMethod.invoke(bundle, parent);
        }
        catch (Exception e) {
          log.log(Level.WARNING, e.getMessage(), e);
        }
      }
     
      parent = bundle;
      matchBundle = bundle;
    }

    bundle = getBaseBundle(name
                           + '_' + locale.getLanguage()
                           + '_' + locale.getCountry()
                           + '_' + locale.getVariant());
   
    if (bundle != null) {
      if (parent != null) {
        try {
          _bundleSetParentMethod.invoke(bundle, parent);
        }
        catch (Exception e) {
          log.log(Level.WARNING, e.getMessage(), e);
        }
      }
     
      parent = bundle;
      matchBundle = bundle;
    }

    if (matchBundle != null) {
      context = new LocalizationContext(matchBundle, locale);
     
      _bundleCache.put(cacheName, context);

      return context;
    }
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

  public LocalizationContext getBundle(String name)
  {
    if (name == null)
      return null;
   
    LocalizationContext bundle = _bundleCache.get(name);
    if (bundle != null)
      return bundle != NULL_BUNDLE ? bundle : null;
   
    ResourceBundle resourceBundle = getBaseBundle(name);
    if (resourceBundle != null) {
      bundle = new LocalizationContext(resourceBundle);
     
      _bundleCache.put(name, bundle);
     
      return bundle;
    }
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

   */
  public static void exposeLocalizationContext(HttpServletRequest request, MessageSource messageSource) {
    Locale jstlLocale = RequestContextUtils.getLocale(request);
    Config.set(request, Config.FMT_LOCALE, jstlLocale);
    if (messageSource != null) {
      LocalizationContext jstlContext = new SpringLocalizationContext(messageSource, request);
      Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, jstlContext);
    }
  }
View Full Code Here

Examples of javax.servlet.jsp.jstl.fmt.LocalizationContext

   */
  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);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.