Example usage for org.apache.wicket.markup.html WebPage getRequestCycle

List of usage examples for org.apache.wicket.markup.html WebPage getRequestCycle

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html WebPage getRequestCycle.

Prototype

public final RequestCycle getRequestCycle() 

Source Link

Document

Gets the active request cycle for this component

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;//ww w .ja  v  a2 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;

}