use of org.apache.wicket.request.cycle.RequestCycle in project wicket by apache.
the class DefaultExceptionMapper method extractCurrentPage.
/**
* @return the page being rendered when the exception was thrown, or {@code null} if it cannot
* be extracted
*/
protected Page extractCurrentPage() {
final RequestCycle requestCycle = RequestCycle.get();
IRequestHandler handler = requestCycle.getActiveRequestHandler();
if (handler == null) {
handler = requestCycle.getRequestHandlerScheduledAfterCurrent();
}
if (handler instanceof IPageRequestHandler) {
IPageRequestHandler pageRequestHandler = (IPageRequestHandler) handler;
return (Page) pageRequestHandler.getPage();
}
return null;
}
use of org.apache.wicket.request.cycle.RequestCycle in project wicket by apache.
the class DefaultExceptionMapper method createPageRequestHandler.
/**
* Creates a {@link RenderPageRequestHandler} for the target page provided by {@code pageProvider}.
*
* Uses {@link RenderPageRequestHandler.RedirectPolicy#NEVER_REDIRECT} policy to preserve the original page's URL
* for non-Ajax requests and {@link RenderPageRequestHandler.RedirectPolicy#AUTO_REDIRECT} for AJAX requests.
*
* @param pageProvider
* the page provider for the target page
* @return the request handler for the target page
*/
protected RenderPageRequestHandler createPageRequestHandler(PageProvider pageProvider) {
RequestCycle requestCycle = RequestCycle.get();
if (requestCycle == null) {
throw new IllegalStateException("there is no current request cycle attached to this thread");
}
RenderPageRequestHandler.RedirectPolicy redirect = RenderPageRequestHandler.RedirectPolicy.NEVER_REDIRECT;
if (isProcessingAjaxRequest()) {
redirect = RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT;
}
return new RenderPageRequestHandler(pageProvider, redirect);
}
use of org.apache.wicket.request.cycle.RequestCycle in project wicket by apache.
the class AbstractDefaultAjaxBehavior method renderHead.
/**
* @see org.apache.wicket.behavior.AbstractAjaxBehavior#renderHead(Component,
* org.apache.wicket.markup.head.IHeaderResponse)
*/
@Override
public void renderHead(final Component component, final IHeaderResponse response) {
super.renderHead(component, response);
CoreLibrariesContributor.contributeAjax(component.getApplication(), response);
RequestCycle requestCycle = component.getRequestCycle();
Url baseUrl = requestCycle.getUrlRenderer().getBaseUrl();
CharSequence ajaxBaseUrl = Strings.escapeMarkup(baseUrl.toString());
response.render(JavaScriptHeaderItem.forScript("Wicket.Ajax.baseUrl=\"" + ajaxBaseUrl + "\";", "wicket-ajax-base-url"));
renderExtraHeaderContributors(component, response);
}
use of org.apache.wicket.request.cycle.RequestCycle in project wicket by apache.
the class AbstractDefaultAjaxBehavior method onRequest.
@Override
public final void onRequest() {
WebApplication app = (WebApplication) getComponent().getApplication();
AjaxRequestTarget target = app.newAjaxRequestTarget(getComponent().getPage());
RequestCycle requestCycle = RequestCycle.get();
requestCycle.scheduleRequestHandlerAfterCurrent(target);
respond(target);
}
use of org.apache.wicket.request.cycle.RequestCycle in project wicket by apache.
the class AjaxClientInfoBehavior method onTimer.
@Override
protected final void onTimer(AjaxRequestTarget target) {
stop(target);
RequestCycle requestCycle = RequestCycle.get();
IRequestParameters requestParameters = requestCycle.getRequest().getRequestParameters();
WebClientInfo clientInfo = newWebClientInfo(requestCycle);
clientInfo.getProperties().read(requestParameters);
Session.get().setClientInfo(clientInfo);
onClientInfo(target, clientInfo);
}
Aggregations