Package org.apache.tapestry5.dom

Examples of org.apache.tapestry5.dom.Document


     * Perhaps the linker should create the <body> element in this case? In the meantime,
     */
    @Test
    public void no_body_element() throws Exception
    {
        Document document = new Document(new XMLMarkupModel());

        document.newRootElement("html").element("notbody").element("p").text("Ready to be updated with scripts.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.addScriptLink("foo.js");

View Full Code Here


    }

    @Test
    public void script_written_raw() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with scripts.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.addScript(InitializationPriority.IMMEDIATE, "for (var i = 0; i < 5; i++)  { doIt(i); }");

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("script_written_raw.txt").trim());
    }
View Full Code Here

    }

    @Test
    public void non_asset_script_link_disables_aggregation() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html").element("body").element("p").text("Ready to be updated with scripts.");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.addScriptLink("/context/foo.js");

        linker.updateDocument(document);

        Element script = document.getRootElement().find("head/script");

        String assetURL = script.getAttribute("src");

        assertEquals(assetURL, "/context/foo.js");
    }
View Full Code Here

    }

    @Test
    public void added_scripts_go_before_existing_script() throws Exception
    {
        Document document = new Document();

        Element head = document.newRootElement("html").element("head");

        head.element("meta");
        head.element("script");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.addScriptLink("/foo.js");

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("added_scripts_go_before_existing_script.txt"));
    }
View Full Code Here

    }

    @Test
    public void immediate_initialization() throws Exception
    {
        Document document = new Document();

        Element head = document.newRootElement("html").element("head");

        head.element("meta");
        head.element("script");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.setInitialization(InitializationPriority.IMMEDIATE, new JSONObject("fred", "barney"));

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("immediate_initialization.txt"));
    }
View Full Code Here

    }

    @Test
    public void pretty_print_initialization() throws Exception
    {
        Document document = new Document();

        Element head = document.newRootElement("html").element("head");

        head.element("meta");
        head.element("script");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", false);

        linker.setInitialization(InitializationPriority.IMMEDIATE, new JSONObject().put("fred", new JSONArray("barney",
                "wilma", "betty")));

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("pretty_print_initialization.txt"));
    }
View Full Code Here

    }

    @Test
    public void other_initialization() throws Exception
    {
        Document document = new Document();

        Element head = document.newRootElement("html").element("head");

        head.element("meta");
        head.element("script");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.setInitialization(InitializationPriority.NORMAL, new JSONObject("fred", "barney"));

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("other_initialization.txt"));
    }
View Full Code Here

    }

    @Test
    public void ie_conditional_stylesheet() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.addStylesheetLink(new StylesheetLink("everybody.css"));
        linker.addStylesheetLink(new StylesheetLink("just_ie.css", new StylesheetOptions().withCondition("IE")));

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("ie_conditional_stylesheet.txt"));
    }
View Full Code Here

    }

    @Test
    public void stylesheet_insertion_point() throws Exception
    {
        Document document = new Document();

        document.newRootElement("html");

        DocumentLinkerImpl linker = new DocumentLinkerImpl(true, "1.2.3", true);

        linker.addStylesheetLink(new StylesheetLink("whatever.css"));
        linker.addStylesheetLink(new StylesheetLink("insertion-point.css", new StylesheetOptions().asAjaxInsertionPoint()));

        linker.updateDocument(document);

        assertEquals(document.toString(), readFile("stylesheet_insertion_point.txt"));

    }
View Full Code Here

    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));
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.dom.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.