use of org.apache.wicket.core.request.handler.ListenerRequestHandler 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;
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler 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;
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler 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;
}
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BaseWicketTester method executeListener.
/**
* Simulates processing URL that invokes an {@link IRequestListener} on a component.
*
* After the listener is invoked the page containing the component will be rendered
* (with an optional redirect - depending on {@link RenderStrategy}).
*
* @param component
* @param listener
*/
public void executeListener(final Component component) {
Args.notNull(component, "component");
// there are two ways to do this. RequestCycle could be forced to call the handler
// directly but constructing and parsing the URL increases the chance of triggering bugs
Page page = component.getPage();
PageAndComponentProvider pageAndComponentProvider = new PageAndComponentProvider(page, component);
IRequestHandler handler = null;
if (page.isPageStateless() || (page.isBookmarkable() && page.wasCreatedBookmarkable())) {
handler = new BookmarkableListenerRequestHandler(pageAndComponentProvider);
} else {
handler = new ListenerRequestHandler(pageAndComponentProvider);
}
Url url = urlFor(handler);
request.setUrl(url);
// Process the request
processRequest(request, null);
}
use of org.apache.wicket.core.request.handler.ListenerRequestHandler in project wicket by apache.
the class BaseWicketTester method invokeListener.
/**
* Simulates invoking an {@link IRequestListener} on a component. As opposed to the
* {@link #executeListener(Component)} method, current request/response objects will be used
*
* After the listener is invoked the page containing the component will be rendered
* (with an optional redirect - depending on {@link RenderStrategy}).
*
* @param component
* @param listener
*/
public void invokeListener(final Component component) {
Args.notNull(component, "component");
// there are two ways to do this. RequestCycle could be forced to call the handler
// directly but constructing and parsing the URL increases the chance of triggering bugs
IRequestHandler handler = new ListenerRequestHandler(new PageAndComponentProvider(component.getPage(), component));
processRequest(handler);
}
Aggregations