Example usage for org.apache.wicket.protocol.http BufferedWebResponse getText

List of usage examples for org.apache.wicket.protocol.http BufferedWebResponse getText

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http BufferedWebResponse getText.

Prototype

public CharSequence getText() 

Source Link

Document

Returns the text already written to this response.

Usage

From source file:gr.abiss.calipso.wicket.BasePanel.java

License:Open Source License

public String renderPageHtmlInNewRequestCycle(Class<? extends WebPage> pageClass,
        PageParameters pageParameters) {
    RequestCycle requestCycle = null;/* w ww .  j a  va2  s.  c o  m*/
    String html = null;
    try {
        BufferedWebResponse bufferedWebResponse = new BufferedWebResponse(null);

        //      
        // call constructor with page parameters
        Constructor constructor = pageClass.getConstructor(new Class[] { PageParameters.class });
        // obtain page instance
        WebPage webPage = (WebPage) constructor.newInstance(pageParameters);
        webPage.getRequestCycle().setResponse(bufferedWebResponse);
        webPage.render();
        html = bufferedWebResponse.getText().toString();
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (requestCycle != null) {
            requestCycle.getResponse().close();
        }
    }
    return html;

}

From source file:org.apache.openmeetings.service.mail.template.AbstractTemplatePanel.java

License:Apache License

/**
 * Collects the html generated by the rendering of a page.
 * /*from  w  ww .j a v  a2s .  com*/
 * @param panel
 *            the panel that should be rendered.
 * @return the html rendered by the panel
 */
protected static CharSequence renderPanel(final Panel panel) {
    RequestCycle requestCycle = RequestCycle.get();

    final Response oldResponse = requestCycle.getResponse();
    BufferedWebResponse tempResponse = new BufferedWebResponse(null);

    try {
        requestCycle.setResponse(tempResponse);

        TemplatePage page = new TemplatePage();
        page.add(panel);

        panel.render();
    } finally {
        requestCycle.setResponse(oldResponse);
    }

    return tempResponse.getText();
}

From source file:org.wicketstuff.poi.excel.TableParser.java

License:Apache License

/**
 * Parse the grid component to a {@link Sheet} object
 *
 * @param tableComponent/*from   w ww. j ava2 s.co  m*/
 * @throws IOException
 * @throws ResourceStreamNotFoundException
 * @throws ParseException
 */
public void parse(Component tableComponent)
        throws IOException, ResourceStreamNotFoundException, ParseException {
    try {
        BufferedWebResponse mockResponse = doRequest(tableComponent);
        doParse(mockResponse.getText(), tableComponent);
    } finally {
        afterParse(tableComponent);
    }
}