Example usage for com.liferay.portal.kernel.util StringUtil replaceToStringBundler

List of usage examples for com.liferay.portal.kernel.util StringUtil replaceToStringBundler

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringUtil replaceToStringBundler.

Prototype

public static StringBundler replaceToStringBundler(String s, String begin, String end,
        Map<String, String> values) 

Source Link

Document

Replaces all occurrences of the keywords found in the substring, defined by the beginning and ending strings, with the new values.

Usage

From source file:com.liferay.dynamic.data.mapping.form.analytics.internal.servlet.taglib.DDMFormAnalyticsDynamicInclude.java

License:Open Source License

@Override
public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException {

    Map<String, String> values = new HashMap<>();

    values.put("analyticsGatewayUrl", getAnalyticsGatewayUrl());

    ScriptData scriptData = new ScriptData();

    scriptData.append(null,/*w  w w . j av  a  2s .  c  o  m*/
            StringUtil.replaceToStringBundler(_TMPL_CONTENT, StringPool.POUND, StringPool.POUND, values), null,
            ScriptData.ModulesType.AUI);

    scriptData.writeTo(response.getWriter());
}

From source file:com.liferay.frontend.js.spa.web.internal.servlet.taglib.SPATopHeadJSPDynamicInclude.java

License:Open Source License

@Override
public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException {

    ScriptData scriptData = new ScriptData();

    Map<String, String> values = new HashMap<>();

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    values.put("cacheExpirationTime",
            String.valueOf(_spaUtil.getCacheExpirationTime(themeDisplay.getCompanyId())));

    values.put("clearScreensCache",
            String.valueOf(_spaUtil.isClearScreensCache(request, request.getSession())));
    values.put("debugEnabled", String.valueOf(_spaUtil.isDebugEnabled()));
    values.put("excludedPaths", _spaUtil.getExcludedPaths());
    values.put("loginRedirect", _html.escapeJS(_spaUtil.getLoginRedirect(request)));
    values.put("message", _language.get(_spaUtil.getLanguageResourceBundle(themeDisplay.getLocale()),
            "it-looks-like-this-is-taking-longer-than-expected"));
    values.put("navigationExceptionSelectors", _spaUtil.getNavigationExceptionSelectors());
    values.put("portletsBlacklist", _spaUtil.getPortletsBlacklist(themeDisplay));
    values.put("requestTimeout", String.valueOf(_spaUtil.getRequestTimeout()));
    values.put("timeout", String.valueOf(_spaUtil.getUserNotificationTimeout()));
    values.put("title", _language.get(_spaUtil.getLanguageResourceBundle(themeDisplay.getLocale()), "oops"));
    values.put("validStatusCodes", _spaUtil.getValidStatusCodes());

    scriptData.append(null,/*from   w  ww  .  j a  v  a  2s.  c o  m*/
            StringUtil.replaceToStringBundler(_TMPL_CONTENT, StringPool.POUND, StringPool.POUND, values),
            "frontend-js-spa-web/liferay/init.es", ScriptData.ModulesType.ES6);

    scriptData.writeTo(response.getWriter());
}