Example usage for org.apache.wicket.request.http.handler ErrorCodeRequestHandler ErrorCodeRequestHandler

List of usage examples for org.apache.wicket.request.http.handler ErrorCodeRequestHandler ErrorCodeRequestHandler

Introduction

In this page you can find the example usage for org.apache.wicket.request.http.handler ErrorCodeRequestHandler ErrorCodeRequestHandler.

Prototype

public ErrorCodeRequestHandler(final int errorCode, final String message) 

Source Link

Document

Construct.

Usage

From source file:com.mastfrog.acteur.wicket.borrowed.SourcesPage.java

License:Apache License

private Class<? extends Page> getPageTargetClass() {
    if (page == null) {
        String pageParam = getPageParameters().get(PAGE_CLASS).toOptionalString();
        if (pageParam == null) {
            if (log.isErrorEnabled()) {
                log.error("key: " + PAGE_CLASS + " is null.");
            }//from w ww. ja  v  a  2s  .  c  om
            getRequestCycle().replaceAllRequestHandlers(
                    new ErrorCodeRequestHandler(404, "Could not find sources for the page you requested"));
        } else if (!pageParam.startsWith("org.apache.wicket.examples")) {
            if (log.isErrorEnabled()) {
                log.error("user is trying to access class: " + pageParam
                        + " which is not in the scope of org.apache.wicket.examples");
            }
            throw new UnauthorizedInstantiationException(getClass());
        }
        page = WicketObjects.resolveClass(pageParam);

        if (page == null) {
            getRequestCycle().replaceAllRequestHandlers(
                    new ErrorCodeRequestHandler(404, "Could not find sources for the page you requested"));
        }
    }
    return page;
}