Search in sources :

Example 26 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class OverrideMethodsTest method override_abstract_methods.

/**
 * TAP5-901
 */
@Test
public void override_abstract_methods() {
    PageTester tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    try {
        Document doc = tester.renderPage("OverrideAbstractMethods");
        assertEquals("6", doc.getElementById("length").getChildMarkup());
    } finally {
        tester.shutdown();
    }
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 27 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class PageNameMetaInjector method renderMarkup.

public void renderMarkup(MarkupWriter writer, MarkupRenderer delegate) {
    delegate.renderMarkup(writer);
    String pageName = globals.getActivePageName();
    Document document = writer.getDocument();
    Element element = document.find("html/head");
    if (element != null) {
        element.element("meta", "name", "tapestry-page-name", "content", pageName);
    }
}
Also used : Element(org.apache.tapestry5.dom.Element) Document(org.apache.tapestry5.dom.Document)

Example 28 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class PartialTemplateRendererImpl method renderAsDocument.

public Document renderAsDocument(Object object) {
    RenderCommand renderCommand = toRenderCommand(object);
    MarkupWriter markupWriter = new MarkupWriterImpl();
    RenderQueueImpl renderQueue = new RenderQueueImpl(LOGGER);
    renderQueue.push(renderCommand);
    renderQueue.run(markupWriter);
    return markupWriter.getDocument();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) MarkupWriter(org.apache.tapestry5.MarkupWriter)

Example 29 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class PageTester method renderPage.

/**
 * Renders a page specified by its name.
 *
 * @param pageName
 *         The name of the page to be rendered.
 * @return The DOM created. Typically you will assert against it.
 */
public Document renderPage(String pageName) {
    renderPageAndReturnResponse(pageName);
    Document result = response.getRenderedDocument();
    if (result == null)
        throw new RuntimeException(String.format("Render of page '%s' did not result in a Document.", pageName));
    return result;
}
Also used : Document(org.apache.tapestry5.dom.Document)

Example 30 with Document

use of org.apache.tapestry5.dom.Document in project tapestry-5 by apache.

the class AddBrowserCompatibilityStyles method renderMarkup.

public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) {
    renderer.renderMarkup(writer);
    Element head = writer.getDocument().find("html/head");
    // Only add the respective style documents if we've rendered an HTML document
    if (head != null) {
        head.raw(ie9);
        head.raw(ie8);
    }
}
Also used : Element(org.apache.tapestry5.dom.Element)

Aggregations

Document (org.apache.tapestry5.dom.Document)20 Test (org.testng.annotations.Test)19 PageTester (org.apache.tapestry5.test.PageTester)11 Element (org.apache.tapestry5.dom.Element)8 MarkupWriter (org.apache.tapestry5.MarkupWriter)4 Document (elemental2.dom.Document)2 Element (elemental2.dom.Element)2 XMLMarkupModel (org.apache.tapestry5.dom.XMLMarkupModel)2 IOException (java.io.IOException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 TestPageForActionLinkWithStream (org.apache.tapestry5.integration.app2.pages.TestPageForActionLinkWithStream)1 TestPageForHttpHeaders (org.apache.tapestry5.integration.app2.pages.TestPageForHttpHeaders)1 Page (org.apache.tapestry5.internal.structure.Page)1 RenderCommand (org.apache.tapestry5.runtime.RenderCommand)1 ComponentLibraryInfo (org.apache.tapestry5.services.ComponentLibraryInfo)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1