Example usage for org.apache.wicket.request.mapper ICompoundRequestMapper remove

List of usage examples for org.apache.wicket.request.mapper ICompoundRequestMapper remove

Introduction

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

Prototype

ICompoundRequestMapper remove(IRequestMapper mapper);

Source Link

Document

Unregisters a IRequestMapper

Usage

From source file:jp.xet.uncommons.wicket.fixedurl.FixedUrlHomePageMapper.java

License:Apache License

/**
 * TODO for daisuke/* www. j av  a 2  s.c  o m*/
 * 
 * @param application {@link Application}
 * @throws NullPointerException ?{@code null}???
 * @since 1.2
 */
public static void replaceHomePageMapper(final Application application) {
    Args.notNull(application, "application");
    ICompoundRequestMapper mappers = application.getRootRequestMapperAsCompound();
    IRequestMapper homePageMapper = null;
    for (IRequestMapper mapper : mappers) {
        if (mapper instanceof HomePageMapper) {
            homePageMapper = mapper;
            break;
        }
    }
    if (homePageMapper != null) {
        mappers.remove(homePageMapper);
    }
    mappers.add(new FixedUrlHomePageMapper(new ClassProvider<Page>(null) {

        @Override
        public Class<Page> get() {
            @SuppressWarnings("unchecked")
            Class<Page> homePage = (Class<Page>) application.getHomePage();
            return homePage;
        }
    }));
}