Example usage for com.liferay.portal.kernel.theme ThemeDisplay isIsolated

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay isIsolated

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay isIsolated.

Prototype

public boolean isIsolated() 

Source Link

Usage

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   www .j  a v a  2  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);
    }
}