Search in sources :

Example 1 with PageRenderRequestHandler

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

the class PageRenderRequestHandlerImplTest method loopback_request.

@Test
public void loopback_request() throws Exception {
    RequestPageCache cache = mockRequestPageCache();
    ComponentEventResultProcessor processor = mockComponentEventResultProcessor();
    PageResponseRenderer renderer = mockPageResponseRenderer();
    Page page = mockPage();
    EventContext context = mockEventContext();
    ComponentPageElement root = mockComponentPageElement();
    InternalComponentResources pageResources = mockInternalComponentResources();
    PageActivator activator = newMock(PageActivator.class);
    Request request = mockRequest();
    train_getAttribute(request, InternalConstants.BYPASS_ACTIVATION, null);
    train_get(cache, "foo/Bar", page);
    train_getRootElement(page, root);
    train_getComponentResources(root, pageResources);
    expect(activator.activatePage(pageResources, context, processor)).andReturn(false);
    // Skips the pageReset()
    renderer.renderPageResponse(page);
    replay();
    PageRenderRequestHandler handler = new PageRenderRequestHandlerImpl(cache, processor, renderer, activator, request);
    PageRenderRequestParameters parameters = new PageRenderRequestParameters("foo/Bar", context, true);
    handler.handle(parameters);
    verify();
}
Also used : EventContext(org.apache.tapestry5.EventContext) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentPageElement(org.apache.tapestry5.internal.structure.ComponentPageElement) ComponentEventResultProcessor(org.apache.tapestry5.services.ComponentEventResultProcessor) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) Request(org.apache.tapestry5.http.services.Request) PageRenderRequestHandler(org.apache.tapestry5.services.PageRenderRequestHandler) Page(org.apache.tapestry5.internal.structure.Page) Test(org.testng.annotations.Test)

Example 2 with PageRenderRequestHandler

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

the class TapestryModule method contributePageRenderRequestHandler.

/**
 * Contributes a single filter, "Secure", which checks for non-secure
 * requests that access secure pages.
 */
public void contributePageRenderRequestHandler(OrderedConfiguration<PageRenderRequestFilter> configuration, final RequestSecurityManager securityManager) {
    PageRenderRequestFilter secureFilter = new PageRenderRequestFilter() {

        public void handle(PageRenderRequestParameters parameters, PageRenderRequestHandler handler) throws IOException {
            if (securityManager.checkForInsecurePageRenderRequest(parameters))
                return;
            handler.handle(parameters);
        }
    };
    configuration.add("Secure", secureFilter);
}
Also used : PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) PageRenderRequestFilter(org.apache.tapestry5.services.PageRenderRequestFilter) PageRenderRequestHandler(org.apache.tapestry5.services.PageRenderRequestHandler)

Aggregations

PageRenderRequestHandler (org.apache.tapestry5.services.PageRenderRequestHandler)2 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)2 EventContext (org.apache.tapestry5.EventContext)1 Request (org.apache.tapestry5.http.services.Request)1 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)1 ComponentPageElement (org.apache.tapestry5.internal.structure.ComponentPageElement)1 Page (org.apache.tapestry5.internal.structure.Page)1 ComponentEventResultProcessor (org.apache.tapestry5.services.ComponentEventResultProcessor)1 PageRenderRequestFilter (org.apache.tapestry5.services.PageRenderRequestFilter)1 Test (org.testng.annotations.Test)1