Package org.apache.tapestry5.dom

Examples of org.apache.tapestry5.dom.Element


    @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


    public Element element(String name, Object... namesAndValues)
    {
        if (current == null)
        {
            Element existingRootElement = document.getRootElement();

            if (existingRootElement != null)
                throw new IllegalStateException(String.format(
                        "A document must have exactly one root element. Element <%s> is already the root element.",
                        existingRootElement.getName()));

            current = document.newRootElement(name);
        }
        else
        {
View Full Code Here

        public void render(MarkupWriter writer, RenderQueue queue)
        {
            rendering = false;

            Element current = writer.getElement();

            if (current != expectedElementAtCompletion)
                throw new TapestryException(StructureMessages.unbalancedElements(completeId), getLocation(), null);

            invoke(false, POST_RENDER_CLEANUP);
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 foo=\"bar\" gnip=\"gnop\">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.getParent(), root);

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

        assertEquals(w.toString(),
View Full Code Here

  /**
   * Creates the RSS file URL and 
   * @param writer
   */
  void afterRender(MarkupWriter writer) {
    final Element head = writer.getDocument().getRootElement().find("head");
    head.element("link", "rel", "alternate", "type", "application/rss+xml", "title", title,
        "href", pageRenderLinkSource.createPageRenderLinkWithContext(Rss.class, context.toArray()).toAbsoluteURI());
  }
View Full Code Here

    @Test
    public void action_link()
    {
        Document document = tester.renderPage(TestPageForActionLinkWithStream.class.getSimpleName());
       
        Element link = document.getElementById("mylink");
       
        assertNotNull(link);
       
        TestableResponse response = tester.clickLinkAndReturnResponse(link);
        assertEquals(response.getOutput(), "<html><body>Rendered with TextStreamResponse</body></html>");
View Full Code Here

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);

        replay();

        Element e = writer.element("label", "accesskey", "f");

        ValidationDecorator decorator = new DefaultValidationDecorator(env, null, null);

        decorator.insideLabel(field, e);
View Full Code Here

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);

        replay();

        Element e = writer.element("label", "accesskey", "f", "class", "foo");

        ValidationDecorator decorator = new DefaultValidationDecorator(env, null, null);

        decorator.insideLabel(field, e);
View Full Code Here

        linker.addScriptLink("/context/assets/foo.js");
        linker.addScriptLink("/context/assets/xyz/bar.js");

        linker.updateDocument(document);

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

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

        String fileName = assetURL.substring("/context/assets/virtual/".length());

        String clientData = fileName.substring(0, fileName.length() - 3);
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.