Example usage for org.jsoup.nodes Document prepend

List of usage examples for org.jsoup.nodes Document prepend

Introduction

In this page you can find the example usage for org.jsoup.nodes Document prepend.

Prototype

public Element prepend(String html) 

Source Link

Document

Add inner HTML into this element.

Usage

From source file:org.jasig.portlet.proxy.service.proxy.document.HeaderFooterFilter.java

@Override
public void filter(Document document, IContentResponse proxyResponse, RenderRequest portletRequest,
        RenderResponse portletResponse) {

    // get any configured header / footer content from the portlet preferences
    final PortletPreferences preferences = portletRequest.getPreferences();
    final String header = preferences.getValue(HEADER_KEY, null);
    final String footer = preferences.getValue(FOOTER_KEY, null);

    // If both a header and footer have been specified, there's some chance they 
    // could be intended to wrap the proxied content.  We can't wrap content 
    // using the prepend / append methods, since those would automatically 
    // close partial elements in each header / footer
    if (StringUtils.isNotBlank(header) && StringUtils.isNotBlank(footer)) {
        document.html(header.concat(document.html()).concat(footer));
    }//from   ww w .ja  v  a2s. c o  m

    else if (StringUtils.isNotBlank(header)) {
        document.prepend(header);
    }

    else if (StringUtils.isNotBlank(footer)) {
        document.append(footer);
    }

}