Search in sources :

Example 1 with ComponentEventRequestHandler

use of org.apache.tapestry5.services.ComponentEventRequestHandler in project tapestry-5 by apache.

the class AjaxFilter method handle.

public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException {
    ComponentEventRequestHandler next = request.isXHR() ? ajaxHandler : handler;
    next.handle(parameters);
}
Also used : ComponentEventRequestHandler(org.apache.tapestry5.services.ComponentEventRequestHandler)

Example 2 with ComponentEventRequestHandler

use of org.apache.tapestry5.services.ComponentEventRequestHandler in project tapestry-5 by apache.

the class UploadExceptionFilter method handle.

@Override
public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException {
    FileUploadException uploadException = decoder.getUploadException();
    if (uploadException != null) {
        Component page = componentSource.getPage(parameters.getActivePageName());
        ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(resultProcessor);
        page.getComponentResources().triggerEvent(UploadEvents.UPLOAD_EXCEPTION, new Object[] { uploadException }, callback);
        if (callback.isAborted())
            return;
        throw new RuntimeException(UploadMessages.unableToDecode(), uploadException);
    }
    handler.handle(parameters);
}
Also used : Component(org.apache.tapestry5.runtime.Component) ComponentResultProcessorWrapper(org.apache.tapestry5.internal.services.ComponentResultProcessorWrapper) FileUploadException(org.apache.commons.fileupload.FileUploadException)

Example 3 with ComponentEventRequestHandler

use of org.apache.tapestry5.services.ComponentEventRequestHandler in project tapestry-5 by apache.

the class TapestryModule method contributeComponentEventRequestHandler.

/**
 * Contributes filters:
 * <dl>
 * <dt>Ajax</dt>
 * <dd>Determines if the request is Ajax oriented, and redirects to an alternative handler if so</dd>
 * <dt>Secure</dt>
 * <dd>Sends a redirect if an non-secure request accesses a secure page</dd>
 * </dl>
 */
public void contributeComponentEventRequestHandler(OrderedConfiguration<ComponentEventRequestFilter> configuration, final RequestSecurityManager requestSecurityManager, @Ajax ComponentEventRequestHandler ajaxHandler) {
    ComponentEventRequestFilter secureFilter = new ComponentEventRequestFilter() {

        public void handle(ComponentEventRequestParameters parameters, ComponentEventRequestHandler handler) throws IOException {
            if (requestSecurityManager.checkForInsecureComponentEventRequest(parameters))
                return;
            handler.handle(parameters);
        }
    };
    configuration.add("Secure", secureFilter);
    configuration.add("Ajax", new AjaxFilter(request, ajaxHandler));
}
Also used : ComponentEventRequestFilter(org.apache.tapestry5.services.ComponentEventRequestFilter) ComponentEventRequestHandler(org.apache.tapestry5.services.ComponentEventRequestHandler) ComponentEventRequestParameters(org.apache.tapestry5.services.ComponentEventRequestParameters)

Aggregations

ComponentEventRequestHandler (org.apache.tapestry5.services.ComponentEventRequestHandler)2 FileUploadException (org.apache.commons.fileupload.FileUploadException)1 ComponentResultProcessorWrapper (org.apache.tapestry5.internal.services.ComponentResultProcessorWrapper)1 Component (org.apache.tapestry5.runtime.Component)1 ComponentEventRequestFilter (org.apache.tapestry5.services.ComponentEventRequestFilter)1 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)1