Search in sources :

Example 1 with ComponentInfo

use of org.apache.wicket.request.mapper.info.ComponentInfo in project wicket by apache.

the class AbstractBookmarkableMapper method processListener.

/**
 * Creates a {@code IRequestHandler} that notifies an {@link IRequestListener}.
 *
 * @param pageComponentInfo
 * @param pageClass
 * @param pageParameters
 * @return a {@code IRequestHandler} that notifies an {@link IRequestListener}.
 */
protected IRequestHandler processListener(PageComponentInfo pageComponentInfo, Class<? extends IRequestablePage> pageClass, PageParameters pageParameters) {
    PageInfo pageInfo = pageComponentInfo.getPageInfo();
    ComponentInfo componentInfo = pageComponentInfo.getComponentInfo();
    Integer renderCount = null;
    if (componentInfo != null) {
        renderCount = componentInfo.getRenderCount();
    }
    PageAndComponentProvider provider = new PageAndComponentProvider(pageInfo.getPageId(), pageClass, pageParameters, renderCount, componentInfo.getComponentPath());
    provider.setPageSource(getContext());
    checkExpiration(provider, pageInfo);
    return new ListenerRequestHandler(provider, componentInfo.getBehaviorId());
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)

Example 2 with ComponentInfo

use of org.apache.wicket.request.mapper.info.ComponentInfo in project wicket by apache.

the class AbstractBookmarkableMapper method mapHandler.

@Override
public Url mapHandler(IRequestHandler requestHandler) {
    // eliminate the need for IRequestHandlerDelegate
    while (requestHandler instanceof IRequestHandlerDelegate) {
        requestHandler = ((IRequestHandlerDelegate) requestHandler).getDelegateHandler();
    }
    if (requestHandler instanceof BookmarkablePageRequestHandler) {
        // simple bookmarkable URL with no page instance information
        BookmarkablePageRequestHandler handler = (BookmarkablePageRequestHandler) requestHandler;
        if (!checkPageClass(handler.getPageClass())) {
            return null;
        }
        PageInfo info = new PageInfo();
        UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null), handler.getPageClass(), handler.getPageParameters());
        return buildUrl(urlInfo);
    } else if (requestHandler instanceof RenderPageRequestHandler) {
        // possibly hybrid URL - bookmarkable URL with page instance information
        // but only allowed if the page was created by bookmarkable URL
        RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
        if (!checkPageClass(handler.getPageClass())) {
            return null;
        }
        if (handler.getPageProvider().isNewPageInstance()) {
            // no existing page instance available, don't bother creating new page instance
            PageInfo info = new PageInfo();
            UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null), handler.getPageClass(), handler.getPageParameters());
            return buildUrl(urlInfo);
        }
        IRequestablePage page = handler.getPage();
        if (checkPageInstance(page) && (!pageMustHaveBeenCreatedBookmarkable() || page.wasCreatedBookmarkable())) {
            PageInfo info = getPageInfo(handler);
            PageComponentInfo pageComponentInfo = new PageComponentInfo(info, null);
            UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(), handler.getPageParameters());
            return buildUrl(urlInfo);
        } else {
            return null;
        }
    } else if (requestHandler instanceof BookmarkableListenerRequestHandler) {
        // request listener URL with page class information
        BookmarkableListenerRequestHandler handler = (BookmarkableListenerRequestHandler) requestHandler;
        Class<? extends IRequestablePage> pageClass = handler.getPageClass();
        if (!checkPageClass(pageClass)) {
            return null;
        }
        Integer renderCount = null;
        if (handler.includeRenderCount()) {
            renderCount = handler.getRenderCount();
        }
        PageInfo pageInfo = getPageInfo(handler);
        ComponentInfo componentInfo = new ComponentInfo(renderCount, handler.getComponentPath(), handler.getBehaviorIndex());
        PageParameters parameters = getRecreateMountedPagesAfterExpiry() ? new PageParameters(handler.getPage().getPageParameters()).mergeWith(handler.getPageParameters()) : handler.getPageParameters();
        UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(pageInfo, componentInfo), pageClass, parameters);
        return buildUrl(urlInfo);
    }
    return null;
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) BookmarkablePageRequestHandler(org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler) BookmarkableListenerRequestHandler(org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) IRequestHandlerDelegate(org.apache.wicket.request.IRequestHandlerDelegate) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Example 3 with ComponentInfo

use of org.apache.wicket.request.mapper.info.ComponentInfo in project wicket by apache.

the class MountedMapper method mapHandler.

@Override
public Url mapHandler(IRequestHandler requestHandler) {
    Url url = super.mapHandler(requestHandler);
    if (url == null && requestHandler instanceof ListenerRequestHandler && getRecreateMountedPagesAfterExpiry()) {
        ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
        IRequestablePage page = handler.getPage();
        if (checkPageInstance(page)) {
            Integer renderCount = null;
            if (handler.includeRenderCount()) {
                renderCount = page.getRenderCount();
            }
            String componentPath = handler.getComponentPath();
            PageInfo pageInfo = getPageInfo(handler);
            ComponentInfo componentInfo = new ComponentInfo(renderCount, componentPath, handler.getBehaviorIndex());
            PageComponentInfo pageComponentInfo = new PageComponentInfo(pageInfo, componentInfo);
            PageParameters parameters = newPageParameters();
            parameters.mergeWith(page.getPageParameters());
            UrlInfo urlInfo = new UrlInfo(pageComponentInfo, page.getClass(), parameters.mergeWith(handler.getPageParameters()));
            url = buildUrl(urlInfo);
        }
    }
    return url;
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Url(org.apache.wicket.request.Url) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Example 4 with ComponentInfo

use of org.apache.wicket.request.mapper.info.ComponentInfo in project wicket by apache.

the class PageInstanceMapper method mapRequest.

/**
 * @see org.apache.wicket.request.IRequestMapper#mapRequest(org.apache.wicket.request.Request)
 */
@Override
public IRequestHandler mapRequest(Request request) {
    if (matches(request)) {
        Url url = request.getUrl();
        PageComponentInfo info = getPageComponentInfo(url);
        if (info != null && info.getPageInfo().getPageId() != null) {
            Integer renderCount = info.getComponentInfo() != null ? info.getComponentInfo().getRenderCount() : null;
            if (info.getComponentInfo() == null) {
                PageProvider provider = new PageProvider(info.getPageInfo().getPageId(), renderCount);
                provider.setPageSource(getContext());
                // render page
                return new RenderPageRequestHandler(provider);
            } else {
                ComponentInfo componentInfo = info.getComponentInfo();
                PageAndComponentProvider provider = new PageAndComponentProvider(info.getPageInfo().getPageId(), renderCount, componentInfo.getComponentPath());
                provider.setPageSource(getContext());
                return new ListenerRequestHandler(provider, componentInfo.getBehaviorId());
            }
        }
    }
    return null;
}
Also used : RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) PageProvider(org.apache.wicket.core.request.handler.PageProvider) PageAndComponentProvider(org.apache.wicket.core.request.handler.PageAndComponentProvider) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) Url(org.apache.wicket.request.Url) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Example 5 with ComponentInfo

use of org.apache.wicket.request.mapper.info.ComponentInfo in project wicket by apache.

the class PageInstanceMapper method mapHandler.

/**
 * @see org.apache.wicket.request.IRequestMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
 */
@Override
public Url mapHandler(IRequestHandler requestHandler) {
    PageComponentInfo info = null;
    if (requestHandler instanceof RenderPageRequestHandler) {
        IRequestablePage page = ((RenderPageRequestHandler) requestHandler).getPage();
        PageInfo i = new PageInfo(page.getPageId());
        info = new PageComponentInfo(i, null);
    } else if (requestHandler instanceof ListenerRequestHandler) {
        ListenerRequestHandler handler = (ListenerRequestHandler) requestHandler;
        IRequestablePage page = handler.getPage();
        String componentPath = handler.getComponentPath();
        Integer renderCount = null;
        if (handler.includeRenderCount()) {
            renderCount = page.getRenderCount();
        }
        PageInfo pageInfo = new PageInfo(page.getPageId());
        ComponentInfo componentInfo = new ComponentInfo(renderCount, componentPath, handler.getBehaviorIndex());
        info = new PageComponentInfo(pageInfo, componentInfo);
    }
    if (info != null) {
        Url url = new Url();
        url.getSegments().add(getContext().getNamespace());
        url.getSegments().add(getContext().getPageIdentifier());
        encodePageComponentInfo(url, info);
        return url;
    } else {
        return null;
    }
}
Also used : PageInfo(org.apache.wicket.request.mapper.info.PageInfo) RenderPageRequestHandler(org.apache.wicket.core.request.handler.RenderPageRequestHandler) IRequestablePage(org.apache.wicket.request.component.IRequestablePage) ListenerRequestHandler(org.apache.wicket.core.request.handler.ListenerRequestHandler) ComponentInfo(org.apache.wicket.request.mapper.info.ComponentInfo) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo) Url(org.apache.wicket.request.Url) PageComponentInfo(org.apache.wicket.request.mapper.info.PageComponentInfo)

Aggregations

ComponentInfo (org.apache.wicket.request.mapper.info.ComponentInfo)5 PageComponentInfo (org.apache.wicket.request.mapper.info.PageComponentInfo)5 ListenerRequestHandler (org.apache.wicket.core.request.handler.ListenerRequestHandler)4 PageInfo (org.apache.wicket.request.mapper.info.PageInfo)4 RenderPageRequestHandler (org.apache.wicket.core.request.handler.RenderPageRequestHandler)3 Url (org.apache.wicket.request.Url)3 IRequestablePage (org.apache.wicket.request.component.IRequestablePage)3 BookmarkableListenerRequestHandler (org.apache.wicket.core.request.handler.BookmarkableListenerRequestHandler)2 PageAndComponentProvider (org.apache.wicket.core.request.handler.PageAndComponentProvider)2 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)2 BookmarkablePageRequestHandler (org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler)1 PageProvider (org.apache.wicket.core.request.handler.PageProvider)1 IRequestHandlerDelegate (org.apache.wicket.request.IRequestHandlerDelegate)1