use of org.apache.wicket.protocol.http.request.urlcompressing.UrlCompressingWebRequestProcessor in project servoy-client by Servoy.
the class WebClientsApplication method newRequestCycleProcessor.
@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return new UrlCompressingWebRequestProcessor() {
@Override
public void respond(RequestCycle requestCycle) {
// execute events from WebClient.invokeLater() before the respond (render) is started
Session session = Session.get();
if (session instanceof WebClientSession && ((WebClientSession) session).getWebClient() != null) {
((WebClientSession) session).getWebClient().executeEvents();
}
super.respond(requestCycle);
}
/**
* @see wicket.protocol.http.WebRequestCycleProcessor#newRequestCodingStrategy()
*/
@Override
protected IRequestCodingStrategy newRequestCodingStrategy() {
Settings settings = Settings.getInstance();
if (// $NON-NLS-1$ //$NON-NLS-2$
Utils.getAsBoolean(settings.getProperty("servoy.webclient.crypt-urls", "true"))) {
return new ServoyCryptedUrlWebRequestCodingStrategy(new UrlCompressingWebCodingStrategy());
} else {
return new UrlCompressingWebCodingStrategy();
}
}
@Override
protected IRequestTarget resolveListenerInterfaceTarget(RequestCycle requestCycle, Page page, String componentPath, String interfaceName, RequestParameters requestParameters) {
try {
IRequestTarget requestTarget = super.resolveListenerInterfaceTarget(requestCycle, page, componentPath, interfaceName, requestParameters);
if (requestTarget instanceof BehaviorRequestTarget) {
Component target = ((BehaviorRequestTarget) requestTarget).getTarget();
if (!(target instanceof Page)) {
boolean invalidPage = false;
Page page2 = null;
try {
// test if it has a page.
page2 = target.findParent(Page.class);
} catch (Exception e) {
Debug.trace(e);
invalidPage = true;
}
if (page2 == null || !page2.getId().equals(page.getId())) {
invalidPage = true;
}
if (invalidPage) {
// $NON-NLS-1$
Debug.log("Couldn't resolve the page of the component, component already gone from page? returning empty");
return EmptyRequestTarget.getInstance();
}
}
}
return requestTarget;
} catch (Exception e) {
// $NON-NLS-1$
Debug.log("couldnt resolve interface, component page already gone from page? returning empty");
}
return EmptyRequestTarget.getInstance();
}
@Override
public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) {
try {
return super.resolve(requestCycle, requestParameters);
} catch (PageExpiredException e) {
// if there is a page expired exception
// then ignore it if there is a current form.
// $NON-NLS-1$
Debug.trace("Page expired, checking for a current form");
Request request = requestCycle.getRequest();
if (request instanceof WebRequest && ((WebRequest) request).isAjax() && requestParameters.isOnlyProcessIfPathActive()) {
// $NON-NLS-1$
Debug.trace("Page expired, it is an ajan/process only if active request");
Session session = Session.get();
if (session instanceof WebClientSession && ((WebClientSession) session).getWebClient() != null) {
WebClient webClient = ((WebClientSession) session).getWebClient();
if (webClient.getFormManager().getCurrentForm() != null) {
// $NON-NLS-1$
Debug.trace("Page expired, there is a current form, ignore this ajax request");
return EmptyAjaxRequestTarget.getInstance();
}
}
}
throw e;
}
}
};
}
Aggregations