Search in sources :

Example 1 with PageRenderRequestParameters

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

the class PageRenderRequestHandlerImpl method handle.

public void handle(PageRenderRequestParameters parameters) throws IOException {
    Page page = cache.get(parameters.getLogicalPageName());
    if (request.getAttribute(InternalConstants.BYPASS_ACTIVATION) == null) {
        if (pageActivator.activatePage(page.getRootElement().getComponentResources(), parameters.getActivationContext(), resultProcessor)) {
            return;
        }
        if (!parameters.isLoopback()) {
            page.pageReset();
        }
    }
    pageResponseRenderer.renderPageResponse(page);
}
Also used : Page(org.apache.tapestry5.internal.structure.Page)

Example 2 with PageRenderRequestParameters

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

the class RequestSecurityManagerImpl method checkForInsecurePageRenderRequest.

public boolean checkForInsecurePageRenderRequest(PageRenderRequestParameters parameters) throws IOException {
    if (!needsRedirect(parameters.getLogicalPageName()))
        return false;
    // Page is secure but request is not, so redirect.
    Link link = componentEventLinkEncoder.createPageRenderLink(parameters);
    response.sendRedirect(link);
    return true;
}
Also used : Link(org.apache.tapestry5.http.Link)

Example 3 with PageRenderRequestParameters

use of org.apache.tapestry5.services.PageRenderRequestParameters 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 4 with PageRenderRequestParameters

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

the class RequestSecurityManagerImplTest method check_page_not_secure.

@Test
public void check_page_not_secure() throws Exception {
    Request request = mockRequest();
    Response response = mockResponse();
    MetaDataLocator locator = mockMetaDataLocator();
    ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
    train_isSecure(request, false);
    train_isSecure(locator, PAGE_NAME, false);
    replay();
    PageRenderRequestParameters parameters = new PageRenderRequestParameters(PAGE_NAME, new EmptyEventContext(), false);
    RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
    assertFalse(manager.checkForInsecurePageRenderRequest(parameters));
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) EmptyEventContext(org.apache.tapestry5.internal.EmptyEventContext) Request(org.apache.tapestry5.http.services.Request) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 5 with PageRenderRequestParameters

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

the class AppPageRenderLinkTransformer method transformPageRenderLink.

public Link transformPageRenderLink(Link defaultLink, PageRenderRequestParameters parameters) {
    if (!parameters.getLogicalPageName().equals("View"))
        return null;
    StringBuilder path = new StringBuilder();
    Locale locale = persistentLocale.get();
    if (locale != null)
        path.append('/').append(locale.toString());
    path.append('/');
    // Cheating: we know there's exactly one value in the context.
    path.append(parameters.getActivationContext().get(String.class, 0));
    return defaultLink.copyWithBasePath(path.toString());
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) Locale(java.util.Locale)

Aggregations

PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)24 Test (org.testng.annotations.Test)14 Request (org.apache.tapestry5.http.services.Request)12 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)11 Link (org.apache.tapestry5.http.Link)10 Response (org.apache.tapestry5.http.services.Response)10 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)9 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)8 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)8 EmptyEventContext (org.apache.tapestry5.internal.EmptyEventContext)6 EventContext (org.apache.tapestry5.EventContext)3 RequestGlobals (org.apache.tapestry5.http.services.RequestGlobals)3 ContextPathEncoder (org.apache.tapestry5.services.ContextPathEncoder)3 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)3 Page (org.apache.tapestry5.internal.structure.Page)2 PageRenderRequestHandler (org.apache.tapestry5.services.PageRenderRequestHandler)2 IOException (java.io.IOException)1 Locale (java.util.Locale)1 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)1 ArrayEventContext (org.apache.tapestry5.internal.services.ArrayEventContext)1