List of usage examples for com.liferay.portal.kernel.util StringUtil replace
public static String replace(String s, String[] oldSubs, String[] newSubs, boolean exactMatch)
From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_2.UpgradeDDMStructure.java
License:Open Source License
protected DDMFormRule getSetVisibleDDMFormRule(String ddmFormFieldName, String visibilityExpression) throws DDMExpressionException { try {//w w w. ja va 2 s. c o m DDMExpression<Boolean> ddmExpression = _ddmExpressionFactory .createBooleanDDMExpression(visibilityExpression); Map<String, VariableDependencies> variableDependencies = ddmExpression.getVariableDependenciesMap(); String condition = visibilityExpression; for (String variable : variableDependencies.keySet()) { condition = StringUtil.replace(condition, new String[] { variable }, new String[] { "getValue(" + StringUtil.quote(variable) + ")" }, true); } return new DDMFormRule(condition, "setVisible('" + ddmFormFieldName + "', true)"); } catch (DDMExpressionException ddmee) { _log.error(String.format("Unable to upgrade the visibility expression \"%s\" to a " + "form rule", visibilityExpression), ddmee); throw ddmee; } }
From source file:com.liferay.layout.admin.web.internal.control.menu.ManageLayoutProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean includeIcon(HttpServletRequest request, HttpServletResponse response) throws IOException { Map<String, String> values = new HashMap<>(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", themeDisplay.getLocale(), getClass());/* w w w . j av a 2s .com*/ values.put("configurePage", _html.escape(_language.get(resourceBundle, "configure-page"))); PortletURL editPageURL = _portal.getControlPanelPortletURL(request, LayoutAdminPortletKeys.GROUP_PAGES, PortletRequest.RENDER_PHASE); Layout layout = themeDisplay.getLayout(); editPageURL.setParameter("mvcRenderCommandName", "/layout/edit_layout"); editPageURL.setParameter("backURL", _portal.getCurrentURL(request)); editPageURL.setParameter("groupId", String.valueOf(layout.getGroupId())); editPageURL.setParameter("selPlid", String.valueOf(layout.getPlid())); editPageURL.setParameter("privateLayout", String.valueOf(layout.isPrivateLayout())); values.put("editPageURL", editPageURL.toString()); try { IconTag iconTag = new IconTag(); iconTag.setCssClass("icon-monospaced"); iconTag.setImage("cog"); iconTag.setMarkupView("lexicon"); PageContext pageContext = PageContextFactoryUtil.create(request, response); values.put("iconCog", iconTag.doTagAsString(pageContext)); SuccessTag successTag = new SuccessTag(); successTag.setKey("layoutUpdated"); successTag.setMessage(_language.get(resourceBundle, "the-page-was-updated-succesfully")); successTag.setTargetNode("#controlMenuAlertsContainer"); values.put("layoutUpdatedMessage", successTag.doTagAsString(pageContext)); } catch (JspException je) { ReflectionUtil.throwException(je); } Writer writer = response.getWriter(); writer.write(StringUtil.replace(_TMPL_CONTENT, "${", "}", values)); return true; }
From source file:com.liferay.portlet.configuration.css.web.internal.servlet.taglib.PortletConfigurationCSSBottomDynamicInclude.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException { PrintWriter printWriter = response.getWriter(); printWriter.print(StringUtil.replace(_TMPL_CONTENT, StringPool.POUND, StringPool.POUND, _values)); }
From source file:com.liferay.product.navigation.product.menu.web.internal.product.navigation.control.menu.ProductMenuProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean includeIcon(HttpServletRequest request, HttpServletResponse response) throws IOException { Map<String, String> values = new HashMap<>(); String portletNamespace = _portal .getPortletNamespace(ProductNavigationProductMenuPortletKeys.PRODUCT_NAVIGATION_PRODUCT_MENU); values.put("portletNamespace", portletNamespace); values.put("title", HtmlUtil.escape(LanguageUtil.get(request, "menu"))); String productMenuState = SessionClicks.get(request, ProductNavigationProductMenuWebKeys.PRODUCT_NAVIGATION_PRODUCT_MENU_STATE, "closed"); if (Objects.equals(productMenuState, "open")) { values.put("cssClass", "active"); values.put("dataURL", StringPool.BLANK); } else {/*from w w w .j a v a 2 s. c o m*/ values.put("cssClass", StringPool.BLANK); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create(request, ProductNavigationProductMenuPortletKeys.PRODUCT_NAVIGATION_PRODUCT_MENU, RenderRequest.RENDER_PHASE); portletURL.setParameter("mvcPath", "/portlet/product_menu.jsp"); portletURL.setParameter("selPpid", portletDisplay.getId()); try { portletURL.setWindowState(LiferayWindowState.EXCLUSIVE); } catch (WindowStateException wse) { ReflectionUtil.throwException(wse); } values.put("dataURL", "data-url='" + portletURL.toString() + "'"); } Writer writer = response.getWriter(); writer.write(StringUtil.replace(_TMPL_CONTENT, "${", "}", values)); return true; }
From source file:com.liferay.product.navigation.simulation.web.internal.product.navigation.control.menu.SimulationProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean includeIcon(HttpServletRequest request, HttpServletResponse response) throws IOException { PortletURL simulationPanelURL = _portletURLFactory.create(request, ProductNavigationSimulationPortletKeys.PRODUCT_NAVIGATION_SIMULATION, PortletRequest.RENDER_PHASE); try {// w w w . j a v a2s . c o m simulationPanelURL.setWindowState(LiferayWindowState.EXCLUSIVE); } catch (WindowStateException wse) { ReflectionUtil.throwException(wse); } Map<String, String> values = new HashMap<>(); IconTag iconTag = new IconTag(); iconTag.setCssClass("icon-monospaced"); iconTag.setImage("simulation-menu-closed"); iconTag.setMarkupView("lexicon"); try { values.put("iconTag", iconTag.doTagAsString(request, response)); } catch (JspException je) { ReflectionUtil.throwException(je); } values.put("portletNamespace", _portletNamespace); values.put("simulationPanelURL", simulationPanelURL.toString()); values.put("title", _html.escape(_language.get(request, "simulation"))); Writer writer = response.getWriter(); writer.write(StringUtil.replace(_ICON_TMPL_CONTENT, "${", "}", values)); return true; }
From source file:com.liferay.product.navigation.simulation.web.internal.product.navigation.control.menu.SimulationProductNavigationControlMenuEntry.java
License:Open Source License
private void _processBodyBottomTagBody(PageContext pageContext) { try {// w ww . ja va2s. c om Map<String, String> values = new HashMap<>(); values.put("portletNamespace", _portletNamespace); MessageTag messageTag = new MessageTag(); messageTag.setKey("simulation"); values.put("sidebarMessage", messageTag.doTagAsString(pageContext)); IconTag iconTag = new IconTag(); iconTag.setCssClass("icon-monospaced sidenav-close"); iconTag.setImage("times"); iconTag.setMarkupView("lexicon"); iconTag.setUrl("javascript:;"); values.put("sidebarIcon", iconTag.doTagAsString(pageContext)); Writer writer = pageContext.getOut(); writer.write(StringUtil.replace(_BODY_TMPL_CONTENT, "${", "}", values)); ScriptTag scriptTag = new ScriptTag(); scriptTag.setUse("liferay-store,io-request,parse-content"); scriptTag.doBodyTag(pageContext, this::_processScriptTagBody); } catch (Exception e) { ReflectionUtil.throwException(e); } }
From source file:com.liferay.product.navigation.simulation.web.internal.product.navigation.control.menu.SimulationProductNavigationControlMenuEntry.java
License:Open Source License
private void _processScriptTagBody(PageContext pageContext) { Writer writer = pageContext.getOut(); try {/*from w w w. j a v a2 s. c o m*/ writer.write(StringUtil.replace(_BODY_SCRIPT_TMPL_CONTENT, "${", "}", Collections.singletonMap("portletNamespace", _portletNamespace))); } catch (IOException ioe) { ReflectionUtil.throwException(ioe); } }