Package org.apache.tapestry5.dom

Examples of org.apache.tapestry5.dom.Element


        if (!rootElementName.equals("html"))
        {
            return;
        }

        Element head = findOrCreateElement(root, "head", true);

        // Create a temporary container element.
        Element container = createTemporaryContainer(head, "style", "stylesheet-container");

        for (int i = 0; i < count; i++)
        {
            stylesheets.get(i).add(container);
        }

        container.pop();
    }
View Full Code Here


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

        {
            final String clientId = javaScriptSupport.allocateClientId(componentResources);

            final String clientValue = encoder.toClient(model.getValue());

            final Element checkbox = writer.element("input", "type", "checkbox", "id", clientId, "name", getControlName(), "value", clientValue);

            if (getSelected().contains(model.getValue()))
            {
                checkbox.attribute("checked", "checked");
            }
            writer.end();

            writer.element("label", "for", clientId);
            writer.write(model.getLabel());
View Full Code Here

    @Test
    public void element_nesting()
    {
        MarkupWriter w = new MarkupWriterImpl();

        Element root = w.element("root");

        w.attributes("foo", "bar");

        w.write("before child");

        assertNotSame(w.element("nested"), root);

        w.write("inner text");

        assertSame(w.end(), root);

        w.write("after child");

        root.attribute("gnip", "gnop");

        assertEquals(w.toString(),
                "<root gnip=\"gnop\" foo=\"bar\">before child<nested>inner text</nested>after child</root>");
    }
View Full Code Here

    @Test
    public void namespaced_elements_and_attributes()
    {
        MarkupWriter w = new MarkupWriterImpl(new XMLMarkupModel());

        Element root = w.elementNS("fredns", "root");

        assertSame(root.defineNamespace("fredns", "fred"), root);

        root.defineNamespace("barneyns", "barney");

        assertSame(w.attributeNS("fredns", "foo", "bar"), root);

        Element child = w.elementNS("barneyns", "child");

        assertSame(child.getContainer(), root);

        w.end(); // child
        w.end(); // root

        assertEquals(
View Full Code Here

     *
     * @param document to be updated
     */
    public void updateDocument(Document document)
    {
        Element root = document.getRootElement();

        // If the document failed to render at all, that's a different problem and is reported elsewhere.

        if (root == null) return;

        if (!stylesheets.isEmpty())
            addStylesheetsToHead(root, includedStylesheets);

        if (!omitGeneratorMetaTag)
        {
            Element head = findOrCreateElement(root, "head", true);
            head.element("meta",
                         "name", "generator",
                         "content", tapestryBanner);
        }

        addScriptElements(root);
View Full Code Here

TOP

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

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.