use of org.apache.wicket.core.request.handler.RenderPageRequestHandler.RedirectPolicy in project wicket by apache.
the class ListenerRequestHandler method respond.
@Override
public void respond(final IRequestCycle requestCycle) {
final IRequestablePage page = getPage();
final boolean freshPage = pageComponentProvider.doesProvideNewPage();
final boolean isAjax = ((WebRequest) requestCycle.getRequest()).isAjax();
IRequestableComponent component;
try {
component = getComponent();
} catch (ComponentNotFoundException e) {
// either the page is stateless and the component we are looking for is not added in the
// constructor
// or the page is stateful+stale and a new instances was created by pageprovider
// we denote this by setting component to null
component = null;
}
if ((component == null && !freshPage) || (component != null && component.getPage() != page)) {
throw new ComponentNotFoundException("Component '" + getComponentPath() + "' has been removed from page.");
}
if (page instanceof Page) {
// initialize the page to be able to check whether it is stateless
((Page) page).internalInitialize();
}
RedirectPolicy policy = page.isPageStateless() ? RedirectPolicy.NEVER_REDIRECT : RedirectPolicy.AUTO_REDIRECT;
boolean blockIfExpired = component != null && !component.canCallListenerAfterExpiry();
boolean lateComponent = component == null && freshPage;
if ((pageComponentProvider.wasExpired() && blockIfExpired) || lateComponent) {
if (LOG.isDebugEnabled()) {
LOG.debug("An IRequestListener was called but its page/component({}) couldn't be resolved. " + "Scheduling re-create of the page and ignoring the listener interface...", getComponentPath());
}
if (isAjax) {
policy = RedirectPolicy.ALWAYS_REDIRECT;
}
requestCycle.scheduleRequestHandlerAfterCurrent(new RenderPageRequestHandler(new PageProvider(page), policy));
return;
}
invokeListener(requestCycle, policy, isAjax);
}
Aggregations