Search in sources :

Example 6 with Page

use of org.apache.tapestry5.internal.structure.Page 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 7 with Page

use of org.apache.tapestry5.internal.structure.Page in project tapestry-5 by apache.

the class RequestPageCacheImpl method get.

public Page get(String pageName) {
    String canonical = resolver.canonicalizePageName(pageName);
    Page page = cache.get(canonical);
    if (page == null) {
        page = pageSource.getPage(canonical);
        try {
            page.attached();
        } catch (Throwable t) {
            throw new RuntimeException(String.format("Unable to attach page %s: %s", canonical, ExceptionUtils.toMessage(t)), t);
        }
        cache.put(canonical, page);
    }
    // A bit of a hack but whatever.
    if (canonical.equals(requestGlobals.getActivePageName())) {
        requestGlobals.getRequest().setAttribute(InternalConstants.ACTIVE_PAGE_LOADED, true);
    }
    return page;
}
Also used : Page(org.apache.tapestry5.internal.structure.Page)

Example 8 with Page

use of org.apache.tapestry5.internal.structure.Page 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 9 with Page

use of org.apache.tapestry5.internal.structure.Page in project tapestry-5 by apache.

the class RenderCommandComponentEventResultProcessor method renderMarkup.

/**
 * As a filter, this class does three things:
 * <ul>
 * <li>It creates an outer element to capture the partial page content that will be rendered</li>
 * <li>It does setup and cleanup with the {@link AjaxFormUpdateController}</li>
 * <li>It extracts the child markup and stuffs it into the reply's "content" property.</li>
 * </ul>
 */
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) {
    // The partial will quite often contain multiple elements (or just a block of plain text),
    // so those must be enclosed in a root element.
    Element root = writer.element("ajax-partial");
    ajaxFormUpdateController.setupBeforePartialZoneRender(writer);
    renderer.renderMarkup(writer, reply);
    ajaxFormUpdateController.cleanupAfterPartialZoneRender();
    writer.end();
    String content = root.getChildMarkup().trim();
    reply.put("content", content);
}
Also used : Element(org.apache.tapestry5.dom.Element)

Example 10 with Page

use of org.apache.tapestry5.internal.structure.Page in project tapestry-5 by apache.

the class BeanBlockSourceImplTest method found_edit_block.

@Test
public void found_edit_block() {
    Block block = mockBlock();
    RequestPageCache cache = mockRequestPageCache();
    Page page = mockPage();
    BeanBlockContribution contribution = new EditBlockContribution("mydata", "MyPage", "mydisplay");
    Collection<BeanBlockContribution> configuration = newList(contribution);
    train_get(cache, "MyPage", page);
    train_getBlock(page, "mydisplay", block);
    replay();
    BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
    // Check case insensitivity while we are at it.
    Block actual = source.getEditBlock("MyData");
    assertSame(actual, block);
    verify();
}
Also used : BeanBlockSource(org.apache.tapestry5.services.BeanBlockSource) Block(org.apache.tapestry5.Block) Page(org.apache.tapestry5.internal.structure.Page) BeanBlockContribution(org.apache.tapestry5.services.BeanBlockContribution) EditBlockContribution(org.apache.tapestry5.services.EditBlockContribution) Test(org.testng.annotations.Test)

Aggregations

Page (org.apache.tapestry5.internal.structure.Page)33 Test (org.testng.annotations.Test)29 Component (org.apache.tapestry5.runtime.Component)17 Link (org.apache.tapestry5.http.Link)13 ComponentResources (org.apache.tapestry5.ComponentResources)10 ComponentPageElement (org.apache.tapestry5.internal.structure.ComponentPageElement)10 ComponentModel (org.apache.tapestry5.model.ComponentModel)10 Document (org.apache.tapestry5.dom.Document)7 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)7 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)6 JSONObject (org.apache.tapestry5.json.JSONObject)6 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)6 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)6 UnknownValueException (org.apache.tapestry5.commons.util.UnknownValueException)5 ContentType (org.apache.tapestry5.http.ContentType)5 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)5 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)5 URL (java.net.URL)4 Binding (org.apache.tapestry5.Binding)4 MarkupWriter (org.apache.tapestry5.MarkupWriter)4