Package javax.servlet.jsp.jstl.fmt

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


    public static String getMessage(String key) {
        return JahiaResourceBundle.getJahiaInternalResource(key, Jahia.getThreadParamBean().getUILocale());
    }

    public LocalizationContext getLocalizationContext() {
        return new LocalizationContext(new JahiaResourceBundle(JahiaResourceBundle.JAHIA_INTERNAL_RESOURCES,Jahia.getThreadParamBean().getUILocale()));
    }
View Full Code Here


        this.getLocale();
        resolveUILocale();
        Config.set(request, Config.FMT_LOCALE, getUILocale());
        // init localization context
        Config.set(request, Config.FMT_LOCALIZATION_CONTEXT,
                new LocalizationContext(new JahiaResourceBundle(getUILocale(), getSite()
                        .getTemplatePackageName()), getUILocale()));           
    }
View Full Code Here

                        request.getSession().setAttribute(ProcessingContext.SESSION_UI_LOCALE, uiLocale);
                        user.setProperty("preferredLanguage", uiLocale.toString());
                    }

                    Config.set(request, Config.FMT_LOCALIZATION_CONTEXT,
                            new LocalizationContext(new JahiaResourceBundle(uiLocale, site.getTemplatePackageName()), uiLocale));

                    AdministrationModulesRegistry modulesRegistry = (AdministrationModulesRegistry) SpringContextSingleton.getInstance().getContext().getBean("administrationModulesRegistry");
                    AdministrationModule currentModule = modulesRegistry.getServerAdministrationModule(operation);
                    if (currentModule != null) {
                        if (hasSitePermission(currentModule.getPermissionName(), site.getSiteKey()) || hasServerPermission(currentModule.getPermissionName())) {
View Full Code Here

     * This method is used to get the resource bundle define in a jsp page.
     * @return return the resource bundle
     */
    public ResourceBundle getCommonResourceBundleForJspPage() {
        Tag t = findAncestorWithClass(this, BundleSupport.class);
        LocalizationContext localizationContext;
        if (t != null) {
            // use resource bundle from parent <bundle> tag
            BundleSupport parent = (BundleSupport) t;
            localizationContext = parent.getLocalizationContext();

      else {
            localizationContext = BundleSupport.getLocalizationContext(pageContext);
        }
        return localizationContext.getResourceBundle();
    }
View Full Code Here

        if (!resource.getContextConfiguration().equals(Resource.CONFIGURATION_INCLUDE)) {
            chain.pushAttribute(request, "moduleMap", new HashMap());
        }

        Script script = (Script) request.getAttribute("script");
        chain.pushAttribute(context.getRequest(), Config.FMT_LOCALIZATION_CONTEXT + ".request", new LocalizationContext(
                new JahiaResourceBundle(resource.getLocale(), script.getView().getModule().getName()),
                resource.getLocale()));
        return null;
    }
View Full Code Here

        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
View Full Code Here

     * Gets the default I18N localization context.
     *
     * @param pc Page in which to look up the default I18N localization context
     */   
    public static LocalizationContext getLocalizationContext(PageContext pc) {
  LocalizationContext locCtxt = null;

  Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT);
  if (obj == null) {
      return null;
  }
View Full Code Here

     * given base name and the locale that led to the resource bundle match,
     * or the empty localization context if no resource bundle match was found
     */
    public static LocalizationContext getLocalizationContext(PageContext pc,
                   String basename) {
  LocalizationContext locCtxt = null;
  ResourceBundle bundle = null;

  if ((basename == null) || basename.equals("")) {
      return new LocalizationContext();
  }

  // Try preferred locales
  Locale pref = SetLocaleSupport.getLocale(pc, Config.FMT_LOCALE);
  if (pref != null) {
      // Preferred locale is application-based
      bundle = findMatch(basename, pref);
      if (bundle != null) {
    locCtxt = new LocalizationContext(bundle, pref);
      }
  } else {
      // Preferred locales are browser-based
      locCtxt = findMatch(pc, basename);
  }
 
  if (locCtxt == null) {
      // No match found with preferred locales, try using fallback locale
      pref = SetLocaleSupport.getLocale(pc, Config.FMT_FALLBACK_LOCALE);
      if (pref != null) {
    bundle = findMatch(basename, pref);
    if (bundle != null) {
        locCtxt = new LocalizationContext(bundle, pref);
    }
      }
  }

  if (locCtxt == null) {
      // try using the root resource bundle with the given basename
      try {
    bundle = ResourceBundle.getBundle(basename, EMPTY_LOCALE);
    if (bundle != null) {
        locCtxt = new LocalizationContext(bundle, null);
    }
      } catch (MissingResourceException mre) {
    // do nothing
      }
  }
    
  if (locCtxt != null) {
      // set response locale
      if (locCtxt.getLocale() != null) {
    SetLocaleSupport.setResponseLocale(pc, locCtxt.getLocale());
      }
  } else {
      // create empty localization context
      locCtxt = new LocalizationContext();
  }

  return locCtxt;
    }
View Full Code Here

    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

    // for JSTL implementations that append the scope to the config names (e.g. Jakarta's)
    request.setAttribute(Config.FMT_LOCALE + REQUEST_SCOPE_SUFFIX, jstlLocale);

    if (messageSource != null) {
      // We've got a Spring MessageSource - expose it as ResourceBundle.
      LocalizationContext jstlContext = new SpringLocalizationContext(messageSource, request);

      // for JSTL implementations that stick to the config names (e.g. Resin's)
      request.setAttribute(Config.FMT_LOCALIZATION_CONTEXT, jstlContext);
      // for JSTL implementations that append the scope to the config names (e.g. Jakarta's)
      request.setAttribute(Config.FMT_LOCALIZATION_CONTEXT + REQUEST_SCOPE_SUFFIX, jstlContext);
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.jstl.fmt.LocalizationContext

Copyright © 2018 www.massapicom. 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.