Example usage for com.liferay.portal.kernel.util WebKeys PAGE_TOP

List of usage examples for com.liferay.portal.kernel.util WebKeys PAGE_TOP

Introduction

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

Prototype

String PAGE_TOP

To view the source code for com.liferay.portal.kernel.util WebKeys PAGE_TOP.

Click Source Link

Usage

From source file:com.commsen.liferay.portlet.customglobalmarkup.CustomGlobalMarkupPortlet.java

License:Open Source License

public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    // get and prepare code to be added to header section
    List<Markup> topMarkups = null;
    try {/*from   w  w  w. jav  a  2  s . co  m*/
        topMarkups = MarkupLocalServiceUtil.getActiveTopMarkups(PortalUtil.getScopeGroupId(renderRequest));
    } catch (PortalException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (topMarkups != null && !topMarkups.isEmpty()) {
        StringBundler sb = (StringBundler) renderRequest.getAttribute(WebKeys.PAGE_TOP);
        if (sb == null)
            sb = new StringBundler();
        for (Markup markup : topMarkups) {
            sb.append(markup.getMarkup()).append("\n");
        }
        renderRequest.setAttribute(WebKeys.PAGE_TOP, sb);
    }

    // get and prepare code to be added to the bottom of the page
    List<Markup> bottomMarkups = null;
    try {
        bottomMarkups = MarkupLocalServiceUtil
                .getActiveBottomMarkups(PortalUtil.getScopeGroupId(renderRequest));
    } catch (PortalException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (bottomMarkups != null && !bottomMarkups.isEmpty()) {
        StringBundler sb = (StringBundler) renderRequest.getAttribute(WebKeys.PAGE_BOTTOM);
        if (sb == null)
            sb = new StringBundler();
        for (Markup markup : bottomMarkups) {
            sb.append(markup.getMarkup()).append("\n");
        }
        renderRequest.setAttribute(WebKeys.PAGE_BOTTOM, sb);
    }
}

From source file:com.liferay.faces.bridge.container.liferay.internal.LiferaySharedPageTop.java

License:Open Source License

public LiferaySharedPageTop(StringBundler stringBundler) {

    try {/*from ww  w  . j a va 2s  . c  o  m*/
        headResources = new ArrayList<HeadResource>();

        SharedPageTopHandler sharedPageTopHandler = new SharedPageTopHandler();
        StringBundler xmlDocument = new StringBundler();
        xmlDocument.append(XML_DOCUMENT_DECLARATION);
        xmlDocument.append(StringPool.LESS_THAN);
        xmlDocument.append(WebKeys.PAGE_TOP);
        xmlDocument.append(StringPool.GREATER_THAN);
        xmlDocument.append(stringBundler);
        xmlDocument.append(StringPool.LESS_THAN);
        xmlDocument.append(StringPool.FORWARD_SLASH);
        xmlDocument.append(WebKeys.PAGE_TOP);
        xmlDocument.append(StringPool.GREATER_THAN);

        String xmlDocumentAsString = xmlDocument.toString();

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlDocumentAsString.getBytes());

        SAXParser saxParser = saxParserFactory.newSAXParser();
        saxParser.parse(byteArrayInputStream, sharedPageTopHandler);

        byteArrayInputStream.close();
    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:com.liferay.faces.bridge.container.liferay.internal.PortletContainerLiferayCompatImpl.java

License:Open Source License

protected StringBundler getPageTop(PortletRequest portletRequest) {

    StringBundler pageTop = null;/*from w  ww . j a va  2  s  . c om*/

    OutputData outputData = (OutputData) portletRequest.getAttribute(WebKeys.OUTPUT_DATA);

    if (outputData != null) {

        pageTop = outputData.getData(null, WebKeys.PAGE_TOP);
    }

    return pageTop;
}

From source file:com.liferay.faces.bridge.container.liferay.internal.PortletContainerLiferayCompatImpl.java

License:Open Source License

protected void setPageTop(PortletRequest portletRequest, StringBundler pageTop) {

    OutputData outputData = (OutputData) portletRequest.getAttribute(WebKeys.OUTPUT_DATA);

    if (outputData != null) {
        outputData.setData(null, WebKeys.PAGE_TOP, pageTop);

        HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);
        httpServletRequest.setAttribute(WebKeys.PAGE_TOP, pageTop);
    }/*w  w w. j  a  v  a  2s .  c  o  m*/
}

From source file:com.liferay.faces.bridge.event.internal.liferay.LiferaySharedPageTop.java

License:Open Source License

public LiferaySharedPageTop(StringBundler stringBundler) {

    try {/*from   ww  w .  j av a 2 s. c o m*/
        headResources = new ArrayList<HeadResource>();

        SharedPageTopHandler sharedPageTopHandler = new SharedPageTopHandler();
        StringBundler xmlDocument = new StringBundler();
        xmlDocument.append(XML_DOCUMENT_DECLARATION);
        xmlDocument.append("<");
        xmlDocument.append(WebKeys.PAGE_TOP);
        xmlDocument.append(">");
        xmlDocument.append(stringBundler);
        xmlDocument.append("</");
        xmlDocument.append(WebKeys.PAGE_TOP);
        xmlDocument.append(">");

        String xmlDocumentAsString = xmlDocument.toString();

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlDocumentAsString.getBytes());

        SAXParser saxParser = saxParserFactory.newSAXParser();
        saxParser.parse(byteArrayInputStream, sharedPageTopHandler);

        byteArrayInputStream.close();
    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:com.liferay.taglib.util.HtmlTopTag.java

License:Open Source License

public HtmlTopTag() {
    super(WebKeys.PAGE_TOP);
}