Example usage for org.springframework.context MessageSource getMessage

List of usage examples for org.springframework.context MessageSource getMessage

Introduction

In this page you can find the example usage for org.springframework.context MessageSource getMessage.

Prototype

@Nullable
String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale);

Source Link

Document

Try to resolve the message.

Usage

From source file:com.mobileman.kuravis.core.util.ValidationUtils.java

public static void rejectIfEmpty(Errors errors, String field, MessageSource messageSource) {
    String capitalizedField = StringUtils.capitalize(field);
    rejectIfEmpty(//  w  ww . j  a v a  2 s . c o  m
            errors, field, "error.required", new String[] { messageSource.getMessage(field, null,
                    capitalizedField, AbstractHealtPlatformController.LOCALE_DEFAULT) },
            capitalizedField + " is required!");
}

From source file:edu.jhuapl.openessence.i18n.SupportedLocale.java

/**
 * @param messageSource to translate displayLanguage
 *///from  w  w w  . j av  a  2s.c  o m
public static SupportedLocale fromLocale(Locale locale, MessageSource messageSource) {
    SupportedLocale sl = new SupportedLocale();
    sl.setCode(locale.toString());

    // display language in target locale, i.e. "espaol" instead of "Spanish"
    String defaultDisplayLanguage = locale.getDisplayLanguage(locale);

    // Java doesn't have every language display name in every language
    // (e.g. doesn't have "Khmer" in Khmer), so use message bundle as fallback
    String lang = messageSource.getMessage("language." + locale.getLanguage(), null, defaultDisplayLanguage,
            locale);

    sl.setDisplayLanguage(lang);

    return sl;
}

From source file:net.solarnetwork.node.backup.FileBackupResourceProvider.java

@Override
public BackupResourceProviderInfo providerInfo(Locale locale) {
    String name = "File Backup Provider";
    String desc = "Backs up system plugins.";
    MessageSource ms = messageSource;
    if (ms != null) {
        name = ms.getMessage("title", null, name, locale);
        desc = ms.getMessage("desc", null, desc, locale);
    }/*  w w  w .  java  2 s  .  c om*/
    return new SimpleBackupResourceProviderInfo(getKey(), name, desc);
}

From source file:net.solarnetwork.node.setup.impl.DefaultKeystoreService.java

@Override
public BackupResourceProviderInfo providerInfo(Locale locale) {
    String name = "Certificate Backup Provider";
    String desc = "Backs up the SolarNode certificates.";
    MessageSource ms = messageSource;
    if (ms != null) {
        name = ms.getMessage("title", null, name, locale);
        desc = ms.getMessage("desc", null, desc, locale);
    }// w w w.j  ava2s. c om
    return new SimpleBackupResourceProviderInfo(getKey(), name, desc);
}

From source file:org.broadleafcommerce.openadmin.web.rulebuilder.service.AbstractRuleBuilderFieldService.java

@Override
public FieldWrapper buildFields() {
    FieldWrapper wrapper = new FieldWrapper();

    for (FieldData field : getFields()) {
        FieldDTO fieldDTO = new FieldDTO();
        fieldDTO.setLabel(field.getFieldLabel());

        //translate the label to display
        String label = field.getFieldLabel();
        BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
        MessageSource messages = context.getMessageSource();
        label = messages.getMessage(label, null, label, context.getJavaLocale());
        fieldDTO.setLabel(label);/*from ww  w  .  j  av a 2  s .  c o  m*/

        fieldDTO.setName(field.getFieldName());
        fieldDTO.setOperators(field.getOperators());
        fieldDTO.setOptions(field.getOptions());
        wrapper.getFields().add(fieldDTO);
    }

    return wrapper;
}

From source file:org.codehaus.groovy.grails.support.MockApplicationContext.java

public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
    MessageSource messageSource = (MessageSource) getBean("messageSource");
    if (messageSource == null) {
        throw new BeanCreationException("No bean [messageSource] found in MockApplicationContext");
    }//from  w w w .  j a va  2 s .  c  o  m
    return messageSource.getMessage(code, args, defaultMessage, locale);
}

From source file:org.displaytag.localization.I18nSpringAdapter.java

/**
 * @see I18nResourceProvider#getResource(String, String, Tag, PageContext)
 *//*from   w  w  w .j a v a 2  s. com*/
public String getResource(String resourceKey, String defaultValue, Tag tag, PageContext pageContext) {
    MessageSource messageSource = RequestContextUtils.getWebApplicationContext(pageContext.getRequest());
    if (messageSource == null) {
        log.warn("messageSource not found");
        return null;
    }

    // if resourceKey isn't defined either, use defaultValue
    String key = (resourceKey != null) ? resourceKey : defaultValue;

    String message = null;

    message = messageSource.getMessage(key, null, null,
            RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest()));

    // if user explicitely added a titleKey we guess this is an error
    if (message == null && resourceKey != null) {
        log.debug(Messages.getString("Localization.missingkey", resourceKey)); //$NON-NLS-1$
        message = UNDEFINED_KEY + resourceKey + UNDEFINED_KEY;
    }

    return message;

}

From source file:org.gbif.portal.web.download.LogEventField.java

/**
 * @see org.gbif.portal.web.download.Field#getFieldValue(org.springframework.context.MessageSource, java.util.Locale, java.lang.String)
 *//*from  w w w .ja va 2  s.  com*/
@Override
public String getFieldValue(MessageSource messageSource, Locale locale, String propertyValue) {
    try {
        if (StringUtils.isNotEmpty(propertyValue)) {
            Integer eventId = Integer.parseInt(propertyValue);
            LogEvent logEvent = LogEvent.get(eventId);
            if (logEvent != null)
                return messageSource.getMessage(logEvent.getName(), null, logEvent.getName(), locale);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    return null;
}

From source file:org.kuali.mobility.tags.PageTag.java

public void doTag() throws JspException {
    PageContext pageContext = (PageContext) getJspContext();
    HttpServletRequest hsr = (HttpServletRequest) pageContext.getRequest();

    Cookie cks[] = hsr.getCookies();/*from w  w w .j  ava  2 s .c  om*/
    if (cks != null) {
        for (Cookie c : cks) {
            if (c.getName().equals("jqmHeader")) {
                jqmHeader = c.getValue();
                //LOG.info("---jqmHeader: " + jqmHeader);
            }
        }
    }

    ServletContext servletContext = pageContext.getServletContext();
    WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(servletContext);

    setAuthMapper((AuthenticationMapper) ac.getBean("authenticationMapper"));
    CoreService coreService = (CoreService) ac.getBean("coreService");
    Properties kmeProperties = (Properties) ac.getBean("kmeProperties");
    Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());
    MessageSource ms = (MessageSource) ac.getBean("messageSource");
    String msgCatString = null;

    User user = (User) pageContext.getSession().getAttribute(AuthenticationConstants.KME_USER_KEY);
    String contextPath = servletContext.getContextPath();
    JspWriter out = pageContext.getOut();
    try {
        out.println("<!DOCTYPE html>");

        if (getAppcacheEnabled().isEmpty()) {
            setAppcacheEnabled(kmeProperties.getProperty("appcache.enabled", "true"));
        }

        LOG.info("param.appcacheEnabled: " + getAppcacheEnabled());

        if (!appcacheEnabled.equals("false")) {
            LOG.debug("Appcache Enabled");
            out.println("<html manifest=\"" + contextPath + "/"
                    + (StringUtils.isEmpty(getAppcacheFilename()) ? "kme.appcache"
                            : getAppcacheFilename().trim())
                    + "\">");
        } else {
            LOG.debug("Appcache Disabled");
            out.println("<html>");
        }

        out.println("<head>");
        out.println("<title>" + getTitle() + "</title>");
        out.println(
                "<link href=\"" + kmeProperties.getProperty("favico.url", "http://www.kuali.org/favicon.ico")
                        + "\" rel=\"icon\" />");
        out.println(
                "<link href=\"" + kmeProperties.getProperty("favico.url", "http://www.kuali.org/favicon.ico")
                        + "\" rel=\"shortcut icon\" />");

        out.println("<link rel=\"apple-touch-icon\" href=\"" + contextPath + "/touch-icon-iphone.png\"/>");
        out.println("<link rel=\"apple-touch-icon\" sizes=\"72x72\" href=\"" + contextPath
                + "/touch-icon-ipad.png\"/>");
        out.println("<link rel=\"apple-touch-icon\" sizes=\"114x114\" href=\"" + contextPath
                + "/touch-icon-iphone-retina.png\"/>");
        out.println("<link rel=\"apple-touch-icon\" sizes=\"144x144\" href=\"" + contextPath
                + "/touch-icon-ipad-retina.png\"/>");

        out.println("<link href=\"" + contextPath
                + "/css/jquery.mobile.css\" rel=\"stylesheet\" type=\"text/css\" />");
        out.println("<link href=\"" + contextPath
                + "/css/jquery-mobile-fluid960.css\" rel=\"stylesheet\" type=\"text/css\" />");
        out.println("<link href=\"" + contextPath + "/css/kme.css\" rel=\"stylesheet\" type=\"text/css\" />");
        out.println("<link href=\"" + contextPath
                + "/css/institution.css\" rel=\"stylesheet\" type=\"text/css\" />");

        addTheme();

        // Attach all CSS files
        for (String cssFile : getCssFilenames()) {
            out.println("<link href=\"" + contextPath + "/css/" + cssFile
                    + ".css\" rel=\"stylesheet\" type=\"text/css\" />");
        }

        out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.js\"></script>");
        out.println(
                "<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.cookie.js\"></script>");
        out.println(
                "<script type=\"text/javascript\" src=\"" + contextPath + "/js/ServerDetails.js\"></script>");
        out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/custom.js\"></script>");
        out.println(
                "<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.mobile.js\"></script>");
        out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.tmpl.js\"></script>");
        out.println(
                "<script type=\"text/javascript\" src=\"" + contextPath + "/js/jquery.validate.js\"></script>");
        out.println("<script type=\"text/javascript\" src=\"" + contextPath
                + "/js/jquery.validate.ready.js\"></script>");
        out.println("<script type=\"text/javascript\" src=\"" + contextPath
                + "/js/jquery.templates.js\"></script>");
        out.println("<script type=\"text/javascript\" src=\"" + contextPath
                + "/js/jquery.transit.min.js\"></script>");
        out.println(
                "<script type=\"text/javascript\" src=\"" + contextPath + "/js/BrowserDetect.js\"></script>");

        if (this.isNative()) {
            out.println(
                    "<script type=\"text/javascript\" src=\"" + contextPath + "/js/PushConfig.js\"></script>");
        }

        //         out.println("<script src=\"http://jsconsole.com/remote.js?2EA94DB3-FD2F-4FF8-B41E-AB2B9A064544\"></script>");
        if (isPlatform(Device.TYPE_IOS)) {
            if (isPhoneGap("1.4.1")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/phonegap-1.4.1.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/ChildBrowser.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/barcodescanner.js\"></script>");
                //                out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/iOS/Connection.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/PushHandler.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/Badge.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/applicationPreferences.js\"></script>");
            } else if (isPhoneGap("1.7.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/cordova-1.7.0.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/ChildBrowser.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/barcodescanner.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/ActionSheet.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/Badge.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/LocalNotifications.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/Notifications.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/PrintPlugin.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/1.7.0/applicationPreferences.js\"></script>");
            } else if (isPhoneGap("2.2.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/cordova-2.2.0.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/ActionSheet.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/applicationPreferences.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/AudioStreamer.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/Badge.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/barcodescanner.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.2.0/ChildBrowser.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/PushHandler.js\"></script>");
            } else if (isPhoneGap("2.3.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.3.0/cordova-2.3.0.js\"></script>");
            } else if (isPhoneGap("2.4.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.4.0/cordova-2.4.0.js\"></script>");
            } else if (isPhoneGap("2.5.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.5.0/cordova-2.5.0.js\"></script>");
            } else if (isPhoneGap("2.6.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.6.0/cordova-2.6.0.js\"></script>");
            } else if (isPhoneGap("2.7.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.7.0/cordova-2.7.0.js\"></script>");
            } else if (isPhoneGap("2.8.1")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/iOS/2.8.1/cordova.js\"></script>");
            }
        } else if (isPlatform(Device.TYPE_ANDROID)) {
            if (isPhoneGap("2.2.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/cordova-2.2.0.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/childbrowser.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/barcodescanner.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/statusbarnotification.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/datePickerPlugin.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/applicationPreferences.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/AudioStreamer.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/GCMPlugin.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/2.2.0/CORDOVA_GCM_script.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/PushHandler.js\"></script>");

            } else {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/android/phonegap-"
                        + getPhonegap() + ".js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/childbrowser.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/barcodescanner.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/statusbarnotification.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/C2DMPlugin.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/PG_C2DM_script.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/android/PushHandler.js\"></script>");
            }
        } else if (isPlatform(Device.TYPE_BLACKBERRY)) {
            if (isPhoneGap("2.2.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/blackberry/2.2.0/cordova-2.2.0.js\"></script>");
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/blackberry/2.2.0/kme-application.js\"></script>");
            }
        } else if (isPlatform(Device.TYPE_WINDOWS)) {
            if (isPhoneGap("2.2.0")) {
                out.println("<script type=\"text/javascript\" src=\"" + contextPath
                        + "/js/windowsMobile/2.2.0/cordova-2.2.0.js\"></script>");
            }
        }

        /* Google Analytics */
        String profileId = coreService.findGoogleAnalyticsProfileId().trim();
        if (!disableGoogleAnalytics && profileId.length() > 0) {
            String profileDomain = coreService.getGoogleAnalyticsProfileDomain().trim();
            if (coreService.isGoogleUniversalAnalytics() && !profileDomain.isEmpty()) {
                out.println("<script type=\"text/javascript\">");
                out.println("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){");
                out.println("(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),");
                out.println("m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)");
                out.println("})(window,document,'script','//www.google-analytics.com/analytics.js','ga');");

                out.println("ga('create', '" + profileId + "', '" + profileDomain + "'); ");
                out.println("ga('send', 'pageview');");
                out.println("</script>");
            } else {
                out.println("<script type=\"text/javascript\">");
                out.println("var _gaq = _gaq || [];");
                out.println("_gaq.push(['_setAccount', '" + profileId + "']);");
                out.println("_gaq.push(['_trackPageview']);");
                out.println("(function() {");
                out.println(
                        "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;");
                out.println(
                        "ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';");
                out.println(
                        "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);");
                out.println("})();");
                out.println("</script>");
            }
        }

        if (isUsesGoogleMaps()) {
            if (getMapLocale() != null) {
                out.println(
                        "<script type=\"text/javascript\" src=\"https://maps.google.com/maps/api/js?sensor=true&language="
                                + getMapLocale() + "\"></script>");
            } else {
                out.println(
                        "<script type=\"text/javascript\" src=\"https://maps.google.com/maps/api/js?sensor=true\"></script>");
            }
        }

        // Now add all the javascripts
        for (String javascript : getJsFilenames()) {
            out.println("<script type=\"text/javascript\" src=\"" + contextPath + "/js/" + javascript
                    + ".js\"></script>");
        }
        out.println(
                "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\">");
        //            out.println("<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />");
        //            out.println("<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\" />");
        out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");

        out.println("</head>");

        if (getOnBodyLoad() != null) {
            out.println("<body onload='" + getOnBodyLoad() + "'>");
        } else {
            out.println("<body>");
        }

        out.println("<div data-role=\"page\" id=\"" + getId() + "\">");

        LOG.info("----" + jqmHeader);
        if (getJqmHeader() != null && getJqmHeader().equals("hide")) {
            LOG.info("---- Hide Header");
            out.println("<div data-role=\"header\" style=\"display:none\">");
        } else if (getJqmHeader() != null && getJqmHeader().equals("fixed")) {
            LOG.info("---- Fixed Header");
            out.println("<div data-role=\"header\" data-position=\"fixed\">");
        } else {
            LOG.info("---- Show Header");
            out.println("<div data-role=\"header\">");
        }

        if (isLoginButton() || getAuthMapper().getLoginURL() != null) {
            if (user == null || user.isPublicUser()) {
                msgCatString = ms.getMessage("shared.login", null, "Login", locale);
                out.println("<a href=\""
                        + (getLoginButtonURL() != null ? getLoginButtonURL()
                                : (getAuthMapper().getLoginURL() != null ? getAuthMapper().getLoginURL()
                                        : contextPath + "/login"))
                        + "\" data-role=\"button\" data-icon=\"lock\">" + msgCatString + "</a>");
            } else {
                msgCatString = ms.getMessage("shared.logout", null, "Logout", locale);
                out.println("<a href=\""
                        + (getLogoutButtonURL() != null ? getLogoutButtonURL()
                                : (getAuthMapper().getLogoutURL() != null ? getAuthMapper().getLogoutURL()
                                        : contextPath + "/logout"))
                        + "\" data-role=\"button\" data-icon=\"unlock\">" + msgCatString + "</a>");
            }
        }
        if (isBackButton()) {
            msgCatString = ms.getMessage("shared.back", null, "Back", locale);
            //            out.println("<a href=\"" + (getBackButtonURL() != null ? getBackButtonURL() : "javascript: history.go(-1)") + "\" class=\"ui-btn-left\" data-icon=\"back\" data-iconpos=\"notext\">" + msgCatString + "</a>");
            boolean showButton = true;
            if (null == this.getPhonegap() || "".equalsIgnoreCase(getPhonegap())) {
                // showButton = true;
            } else {
                if (null != kmeProperties) {
                    StringBuilder builder = new StringBuilder("shim.backbutton.");
                    builder.append(this.getPlatform().toLowerCase());
                    if (kmeProperties.containsKey(builder.toString())
                            && "false".equalsIgnoreCase(kmeProperties.getProperty(builder.toString()))) {
                        showButton = false;
                    }
                }
            }
            if (showButton) {
                out.println("<a href=\""
                        + ((getBackButtonURL() != null && StringUtils.isNotBlank(getBackButtonURL()))
                                ? getBackButtonURL()
                                : "javascript: history.go(-1)")
                        + "\" class=\"ui-btn-left\" data-icon=\"back\" data-iconpos=\"notext\">" + msgCatString
                        + "</a>");
            }
        }
        out.println("<h1>" + getTitle() + "</h1>");
        if (isPreferencesButton()) {
            if (null != kmeProperties
                    && "true".equalsIgnoreCase(kmeProperties.getProperty("home.preferences.enabled", "true"))) {
                msgCatString = ms.getMessage("shared.preferences", null, "Preferences", locale);
                out.println("<a href=\""
                        + (getPreferencesButtonURL() != null ? getPreferencesButtonURL()
                                : contextPath + "/preferences")
                        + "\" class=\"ui-btn-right\" data-icon=\"gear\" data-iconpos=\"notext\">" + msgCatString
                        + "</a>");
            }
        }
        if (isHomeButton()) {
            msgCatString = ms.getMessage("shared.home", null, "Home", locale);
            //            out.println("<a href=\"" + contextPath + "/home\" class=\"ui-btn-right\" data-icon=\"home\" data-iconpos=\"notext\">" + msgCatString + "</a>");
            boolean homeButton = true;
            if (null == this.getPhonegap() || "".equalsIgnoreCase(getPhonegap())) {
                // showButton = true;
            } else {
                if (null != kmeProperties) {
                    StringBuilder builder = new StringBuilder("shim.homebutton.");
                    builder.append(this.getPlatform().toLowerCase());
                    if (kmeProperties.containsKey(builder.toString())
                            && "false".equalsIgnoreCase(kmeProperties.getProperty(builder.toString()))) {
                        homeButton = false;
                    }
                }
            }
            if (homeButton) {
                out.println("<a href=\"" + contextPath
                        + "/home\" class=\"ui-btn-right\" data-icon=\"home\" data-iconpos=\"notext\">"
                        + msgCatString + "</a>");
            }
        }
        out.println("</div>");
        getJspBody().invoke(out);
        out.println("</div>");
        out.println("</body>");
        out.println("</html>");
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
}

From source file:org.sipfoundry.sipxconfig.site.setting.SettingEditor.java

/**
 * Retrieve default value for current setting. This is less than ideal implementation since
 * Enum and Boolean types are treated very differently from all other types.
 *//*from w ww  . j ava2 s. c  o m*/
public String getDefaultValue() {
    Setting setting = getSetting();
    SettingType type = setting.getType();
    String defaultValue = setting.getDefaultValue();
    if (defaultValue == null) {
        // no need to localize empty default labels
        return null;
    }
    String defaultValueLabel = type.getLabel(defaultValue);
    if (type instanceof EnumSetting) {
        MessageSource messageSource = getMessageSource();
        if (messageSource != null) {
            EnumSetting enumType = (EnumSetting) type;
            String code = enumType.getLabelKey(setting, defaultValue);
            Locale locale = getPage().getLocale();
            return messageSource.getMessage(code, null, defaultValueLabel, locale);
        }

    } else if (type instanceof BooleanSetting) {
        return LocalizationUtils.getMessage(getMessages(), defaultValueLabel, defaultValueLabel);
    }
    return defaultValueLabel;
}