Search in sources :

Example 1 with ICompoundRequestMapper

use of org.apache.wicket.request.mapper.ICompoundRequestMapper in project wicket by apache.

the class Application method getRootRequestMapperAsCompound.

/**
 * Converts the root mapper to a {@link ICompoundRequestMapper} if necessary and returns the
 * converted instance.
 *
 * @return compound instance of the root mapper
 */
public final ICompoundRequestMapper getRootRequestMapperAsCompound() {
    IRequestMapper root = getRootRequestMapper();
    if (!(root instanceof ICompoundRequestMapper)) {
        root = new SystemMapper(this).add(root);
        setRootRequestMapper(root);
    }
    return (ICompoundRequestMapper) root;
}
Also used : ICompoundRequestMapper(org.apache.wicket.request.mapper.ICompoundRequestMapper) IRequestMapper(org.apache.wicket.request.IRequestMapper)

Example 2 with ICompoundRequestMapper

use of org.apache.wicket.request.mapper.ICompoundRequestMapper in project wicket by apache.

the class WebApplication method unmount.

/**
 * Unregisters all {@link IRequestMapper}s which would match on a this path.
 * <p>
 * Useful in OSGi environments where a bundle may want to update the mount point.
 * </p>
 *
 * @param path
 *            the path to unmount
 */
public void unmount(String path) {
    Args.notNull(path, "path");
    if (path.charAt(0) == '/') {
        path = path.substring(1);
    }
    IRequestMapper mapper = getRootRequestMapper();
    while (mapper instanceof IRequestMapperDelegate) {
        mapper = ((IRequestMapperDelegate) mapper).getDelegateMapper();
    }
    /*
		 * Only attempt to unmount if root request mapper is either a compound, or wraps a compound to avoid leaving the
		 * application with no mappers installed.
		 */
    if (mapper instanceof ICompoundRequestMapper) {
        final Url url = Url.parse(path);
        Request request = new Request() {

            @Override
            public Url getUrl() {
                return url;
            }

            @Override
            public Url getClientUrl() {
                return url;
            }

            @Override
            public Locale getLocale() {
                return null;
            }

            @Override
            public Charset getCharset() {
                return null;
            }

            @Override
            public Object getContainerRequest() {
                return null;
            }
        };
        unmountFromCompound((ICompoundRequestMapper) mapper, request);
    }
}
Also used : ICompoundRequestMapper(org.apache.wicket.request.mapper.ICompoundRequestMapper) IRequestMapperDelegate(org.apache.wicket.request.mapper.IRequestMapperDelegate) WebRequest(org.apache.wicket.request.http.WebRequest) Request(org.apache.wicket.request.Request) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) IRequestMapper(org.apache.wicket.request.IRequestMapper) Url(org.apache.wicket.request.Url)

Aggregations

IRequestMapper (org.apache.wicket.request.IRequestMapper)2 ICompoundRequestMapper (org.apache.wicket.request.mapper.ICompoundRequestMapper)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)1 Request (org.apache.wicket.request.Request)1 Url (org.apache.wicket.request.Url)1 WebRequest (org.apache.wicket.request.http.WebRequest)1 IRequestMapperDelegate (org.apache.wicket.request.mapper.IRequestMapperDelegate)1