Example usage for org.apache.wicket.core.request.mapper MountedMapper MountedMapper

List of usage examples for org.apache.wicket.core.request.mapper MountedMapper MountedMapper

Introduction

In this page you can find the example usage for org.apache.wicket.core.request.mapper MountedMapper MountedMapper.

Prototype

public MountedMapper(String mountPath, Supplier<Class<? extends IRequestablePage>> pageClassProvider,
        IPageParametersEncoder pageParametersEncoder) 

Source Link

Document

Construct.

Usage

From source file:com.evolveum.midpoint.web.application.DescriptorLoader.java

License:Apache License

private void mountPage(PageDescriptor descriptor, Class clazz, MidPointApplication application)
        throws InstantiationException, IllegalAccessException {

    for (String url : descriptor.url()) {
        IPageParametersEncoder encoder = descriptor.encoder().newInstance();

        LOGGER.trace("Mounting page '{}' to url '{}' with encoder '{}'.",
                new Object[] { clazz.getName(), url, encoder.getClass().getSimpleName() });

        application.mount(new MountedMapper(url, clazz, encoder));
    }//from www  . ja v  a2  s. co  m
}

From source file:com.evolveum.midpoint.web.security.MidPointApplication.java

License:Apache License

@Override
public void init() {
    super.init();

    getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    IResourceSettings resourceSettings = getResourceSettings();
    resourceSettings.setHeaderItemComparator(new PriorityFirstComparator(true));

    resourceSettings.setThrowExceptionOnMissingResource(false);
    getMarkupSettings().setStripWicketTags(true);
    getMarkupSettings().setDefaultBeforeDisabledLink("");
    getMarkupSettings().setDefaultAfterDisabledLink("");

    if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
        getDebugSettings().setAjaxDebugModeEnabled(true);
        getDebugSettings().setDevelopmentUtilitiesEnabled(true);
    }// ww w . j  a v  a  2s. com

    //pretty url for resources (e.g. images)
    mountFiles(ImgResources.BASE_PATH, ImgResources.class);

    //exception handling an error pages
    IApplicationSettings appSettings = getApplicationSettings();
    appSettings.setAccessDeniedPage(PageError401.class);
    appSettings.setInternalErrorPage(PageError.class);
    appSettings.setPageExpiredErrorPage(PageError.class);

    mount(new MountedMapper("/error", PageError.class, MidPointPageParametersEncoder.ENCODER));
    mount(new MountedMapper("/error/401", PageError401.class, MidPointPageParametersEncoder.ENCODER));
    mount(new MountedMapper("/error/403", PageError403.class, MidPointPageParametersEncoder.ENCODER));
    mount(new MountedMapper("/error/404", PageError404.class, MidPointPageParametersEncoder.ENCODER));

    getRequestCycleListeners().add(new AbstractRequestCycleListener() {

        @Override
        public IRequestHandler onException(RequestCycle cycle, Exception ex) {
            return new RenderPageRequestHandler(new PageProvider(new PageError(ex)));
        }
    });

    // todo wicket atmosphere was disabled because of form file upload and redirection url problems.
    //        //ajax push (just an experiment)
    //        eventBus = new EventBus(this);
    //        eventBus.getParameters().setLogLevel(AtmosphereLogLevel.DEBUG);
    //
    //        //enable simple task notifications here
    //        taskManager.registerTaskListener(new TaskListener() {
    //
    //            @Override
    //            public void onTaskStart(Task task) {
    //                EventBus bus = getEventBus();
    //                bus.post(new NotifyMessage("Task start", WebMiscUtil.getOrigStringFromPoly(task.getName()) + " started.",
    //                        OperationResultStatus.SUCCESS));
    //            }
    //
    //            @Override
    //            public void onTaskFinish(Task task, TaskRunResult runResult) {
    //                EventBus bus = getEventBus();
    //                bus.post(new NotifyMessage("Task finish", WebMiscUtil.getOrigStringFromPoly(task.getName()) + " finished.",
    //                        OperationResultStatus.parseStatusType(task.getResultStatus())));
    //            }
    //
    //            @Override
    //            public void onTaskThreadStart(Task task, boolean isRecovering) {
    //
    //            }
    //
    //            @Override
    //            public void onTaskThreadFinish(Task task) {
    //
    //            }
    //        });

    //descriptor loader, used for customization
    new DescriptorLoader().loadData(this);
}

From source file:de.alpharogroup.wicket.base.application.BaseWebApplication.java

License:Apache License

/**
 * Mounts a page class to the given path with the given {@link IPageParametersEncoder}.
 *
 * @param <T>/* w w  w.j  av  a2 s  . c om*/
 *            type of page
 *
 * @param path
 *            the path to mount the page class on
 * @param pageClass
 *            the page class to be mounted
 * @param pageParametersEncoder
 *            the encoder for the page parameter to be mounted
 */
public <T extends Page> void mountPage(final String path, final Class<T> pageClass,
        final IPageParametersEncoder pageParametersEncoder) {
    mount(new MountedMapper(path, pageClass, pageParametersEncoder));
}

From source file:dk.frankbille.scoreboard.ScoreBoardApplication.java

License:Open Source License

/**
 * @see org.apache.wicket.Application#init()
 *//* ww w.  jav  a 2 s. c o m*/
@Override
public void init() {
    super.init();

    // Always strip Wicket tags
    getMarkupSettings().setStripWicketTags(true);

    getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    getSecuritySettings().setAuthorizationStrategy(new ScoreBoardAuthorizationStrategy());

    getMarkupSettings().setDefaultBeforeDisabledLink("");
    getMarkupSettings().setDefaultAfterDisabledLink("");

    mount(new MountedMapper("/daily", DailyGamePage.class, new UrlPathPageParametersEncoder()));
    mountPage("/game", EditGamePage.class);
    mountPage("/player/edit", PlayerEditPage.class);
    mountPage("/player", PlayerPage.class);
    mountPage("/players", PlayerListPage.class);
    mountPage("/leagues", LeagueListPage.class);
    mountPage("/league/edit", LeagueEditPage.class);
    mountPage("/login", LoginPage.class);
    mountPage("/logout", LogoutPage.class);
}

From source file:org.wicketTutorial.pageparamsencode.WicketApplication.java

License:Apache License

/**
 * @see org.apache.wicket.Application#init()
 *//*from  w w  w .  j a va  2s . co m*/
@Override
public void init() {
    super.init();

    mount(new MountedMapper("/mountedPath", MountedPage.class, new UrlPathPageParametersEncoder()));
}

From source file:sk.lazyman.gizmo.security.GizmoApplication.java

License:Apache License

@Override
public void init() {
    super.init();

    IBootstrapSettings settings = new BootstrapSettings();
    settings.setAutoAppendResources(false);
    settings.setThemeProvider(new GizmoThemeProvider());
    Bootstrap.install(this, settings);
    BootstrapLess.install(this);

    getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    IResourceSettings resourceSettings = getResourceSettings();

    resourceSettings.setThrowExceptionOnMissingResource(false);
    getMarkupSettings().setStripWicketTags(true);
    getMarkupSettings().setDefaultBeforeDisabledLink("");
    getMarkupSettings().setDefaultAfterDisabledLink("");

    if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
        getDebugSettings().setAjaxDebugModeEnabled(true);
        getDebugSettings().setDevelopmentUtilitiesEnabled(true);
    }/*from www .ja va 2  s.c  om*/

    //exception handling an error pages
    IApplicationSettings appSettings = getApplicationSettings();
    appSettings.setAccessDeniedPage(PageError401.class);
    appSettings.setInternalErrorPage(PageError.class);
    appSettings.setPageExpiredErrorPage(PageError.class);

    new AnnotatedMountScanner().scanPackage(PageTemplate.class.getPackage().getName()).mount(this);

    mount(new MountedMapper("/error", PageError.class, new UrlPathPageParametersEncoder()));
    mount(new MountedMapper("/error/401", PageError401.class, new UrlPathPageParametersEncoder()));
    mount(new MountedMapper("/error/403", PageError403.class, new UrlPathPageParametersEncoder()));
    mount(new MountedMapper("/error/404", PageError404.class, new UrlPathPageParametersEncoder()));

    getRequestCycleListeners().add(new AbstractRequestCycleListener() {

        @Override
        public IRequestHandler onException(RequestCycle cycle, Exception ex) {
            LOGGER.error("Error occurred during page rendering, reason: {} (more on DEBUG level)",
                    ex.getMessage());
            LOGGER.debug("Error occurred during page rendering", ex);

            return new RenderPageRequestHandler(new PageProvider(new PageError(ex)));
        }
    });
}