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);
}
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;
}
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();
}
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();
}
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());
}
Aggregations