Example usage for org.apache.wicket.request.cycle RequestCycle find

List of usage examples for org.apache.wicket.request.cycle RequestCycle find

Introduction

In this page you can find the example usage for org.apache.wicket.request.cycle RequestCycle find.

Prototype

@SuppressWarnings("unchecked")
public <T extends IRequestHandler> Optional<T> find(final Class<T> type) 

Source Link

Document

Finds a IRequestHandler which is either the currently executing handler or is scheduled to be executed.

Usage

From source file:name.martingeisse.wicket.util.WicketPageUtil.java

License:Open Source License

/**
 * Redirects to a new instance of the current page class, with the current page
 * parameters. Useful to escape when stuck in a stateful page with outdated values.
 *//*from w  w w.  ja  v  a  2  s. c o  m*/
public static void setResponsePageToNewPageInstance() {
    RequestCycle requestCycle = RequestCycle.get();
    IPageClassRequestHandler requestHandler = requestCycle.find(IPageClassRequestHandler.class);
    if (requestHandler == null) {
        throw new IllegalStateException("no IPageClassRequestHandler found");
    }
    requestCycle.setResponsePage(requestHandler.getPageClass(), requestHandler.getPageParameters());
}