List of usage examples for com.liferay.portal.kernel.servlet.taglib.aui ScriptData ScriptData
ScriptData
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,/*from w w w .jav a 2 s .co m*/ StringUtil.replaceToStringBundler(_TMPL_CONTENT, StringPool.POUND, StringPool.POUND, values), null, ScriptData.ModulesType.AUI); scriptData.writeTo(response.getWriter()); }
From source file:com.liferay.faces.bridge.client.internal.ClientScriptLiferayImpl.java
License:Open Source License
@Override public void append(String content, String options) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); Map<String, Object> requestMap = externalContext.getRequestMap(); if (scriptData == null) { scriptData = (ScriptData) requestMap.get(WebKeys.AUI_SCRIPT_DATA); if (scriptData == null) { scriptData = new ScriptData(); requestMap.put(WebKeys.AUI_SCRIPT_DATA, scriptData); }//from w ww . j a v a 2 s.co m } String portletId = StringPool.BLANK; Object portlet = requestMap.get(WebKeys.RENDER_PORTLET); if (portlet != null) { portletId = LiferayPortletUtil.getPortletId(portlet); } appendScriptData(scriptData, portletId, content, options); }
From source file:com.liferay.faces.bridge.ext.renderkit.html_basic.internal.ScriptsEncoderLiferayImpl.java
License:Open Source License
@Override public void encodeBodyScripts(FacesContext facesContext, List<Script> scripts) throws IOException { ExternalContext externalContext = facesContext.getExternalContext(); Map<String, Object> requestMap = externalContext.getRequestMap(); ThemeDisplay themeDisplay = (ThemeDisplay) requestMap.get(WebKeys.THEME_DISPLAY); // If the portlet is being rendered on its own, then render the scripts immediately before the closing <div> // of the portlet. if (themeDisplay.isStateExclusive() || themeDisplay.isIsolated()) { String scriptsString = getScriptsAsString(facesContext, scripts); ResponseWriter responseWriter = facesContext.getResponseWriter(); responseWriter.write(scriptsString); }//from w w w. j a va2 s . c o m // Otherwise, allow Liferay to render the scripts at the bottom of the page before the closing <body> tag. else { ScriptData scriptData = (ScriptData) requestMap.get(WebKeys.AUI_SCRIPT_DATA); if (scriptData == null) { scriptData = new ScriptData(); requestMap.put(WebKeys.AUI_SCRIPT_DATA, scriptData); } scriptDataAppendScripts(scriptData, requestMap, scripts); } }
From source file:com.liferay.faces.bridge.ext.renderkit.html_basic.internal.ScriptsEncoderLiferayImpl.java
License:Open Source License
private String getScriptsAsString(FacesContext facesContext, List<Script> scripts) throws IOException { ScriptData scriptData = new ScriptData(); ExternalContext externalContext = facesContext.getExternalContext(); Map<String, Object> requestMap = externalContext.getRequestMap(); scriptDataAppendScripts(scriptData, requestMap, scripts); return scriptDataToString(externalContext, scriptData); }
From source file:com.liferay.faces.bridge.renderkit.html_basic.internal.BodyRendererBridgeCompatImpl.java
License:Open Source License
protected void encodeScripts(FacesContext facesContext, ResponseWriter responseWriter, UIComponent uiComponent) throws IOException { FacesRequestContext facesRequestContext = FacesRequestContext.getCurrentInstance(); List<Script> scripts = facesRequestContext.getScripts(); if (LIFERAY_PORTAL_DETECTED) { ExternalContext externalContext = facesContext.getExternalContext(); Map<String, Object> requestMap = externalContext.getRequestMap(); ScriptData scriptData = (ScriptData) requestMap.get(WebKeys.AUI_SCRIPT_DATA); if (scriptData == null) { scriptData = new ScriptData(); requestMap.put(WebKeys.AUI_SCRIPT_DATA, scriptData); }/* w w w. j a v a 2 s . com*/ ScriptDataUtil.scriptDataAppendScripts(scriptData, requestMap, scripts); } else { responseWriter.startElement("script", uiComponent); responseWriter.writeAttribute("type", "text/javascript", null); BridgeScriptUtil.writeScripts(responseWriter, scripts); responseWriter.endElement("script"); } }
From source file:com.liferay.faces.util.client.internal.ClientScriptLiferayImpl.java
License:Open Source License
@Override public void append(String content, String use) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); Map<String, Object> requestMap = externalContext.getRequestMap(); if (scriptData == null) { scriptData = new ScriptData(); requestMap.put(WebKeys.AUI_SCRIPT_DATA, scriptData); }/*from w w w . j a va 2 s . c om*/ String portletId = StringPool.BLANK; Object portlet = requestMap.get(WebKeys.RENDER_PORTLET); if (portlet != null) { portletId = LiferayPortletUtil.getPortletId(portlet); } appendScriptData(scriptData, portletId, content, use); }
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,/*w w w . j a v a2 s . co m*/ StringUtil.replaceToStringBundler(_TMPL_CONTENT, StringPool.POUND, StringPool.POUND, values), "frontend-js-spa-web/liferay/init.es", ScriptData.ModulesType.ES6); scriptData.writeTo(response.getWriter()); }
From source file:com.liferay.taglib.aui.ScriptTag.java
License:Open Source License
@Override public int doEndTag() throws JspException { HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); boolean positionInline = isPositionInLine(); try {//from ww w . j a va 2 s. c o m StringBundler bodyContentSB = getBodyContentAsStringBundler(); String use = getUse(); if (positionInline) { ScriptData scriptData = new ScriptData(); request.setAttribute(ScriptTag.class.getName(), scriptData); scriptData.append(bodyContentSB, use); String page = getPage(); if (FileAvailabilityUtil.isAvailable(pageContext.getServletContext(), page)) { PortalIncludeUtil.include(pageContext, page); } else { processEndTag(scriptData); } } else { ScriptData scriptData = (ScriptData) request.getAttribute(WebKeys.AUI_SCRIPT_DATA); if (scriptData == null) { scriptData = new ScriptData(); request.setAttribute(WebKeys.AUI_SCRIPT_DATA, scriptData); } scriptData.append(bodyContentSB, use); } return EVAL_PAGE; } catch (Exception e) { throw new JspException(e); } finally { if (positionInline) { request.removeAttribute(ScriptTag.class.getName()); } if (!ServerDetector.isResin()) { cleanUp(); } } }