Package org.apache.tapestry

Examples of org.apache.tapestry.MarkupWriter


    }

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

        w.element("root");
        w.write("before");
        w.comment("A comment");
        w.write("after");
        w.end();

        assertEquals(w.toString(), "<root>before<!-- A comment -->after</root>");
    }
View Full Code Here


    }

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

        w.element("root");
        w.write(null);
        w.end();

        assertEquals(w.toString(), "<root></root>");
    }
View Full Code Here

    }

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

        w.element("root");
        w.writef("Test name: %s", "writef");

        assertEquals(w.toString(), "<root>Test name: writef</root>");
    }
View Full Code Here

    @Test
    public void writer_notifies_map_about_links()
    {
        ComponentInvocationMap map = newComponentInvocationMap();

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), map);
        Link link = newLink();

        Element e = writer.element("form");

        map.store(e, link);

        replay();

        writer.attributes("action", link);

        verify();
    }
View Full Code Here

    }

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

        w.element("root");
        w.write("<");
        w.writeRaw("&nbsp;");
        w.write(">");
        w.end();

        assertEquals(w.toString(), "<root>&lt;&nbsp;&gt;</root>");
    }
View Full Code Here

     */
    public Document invoke(ComponentInvocation invocation)
    {
        try
        {
            final MarkupWriter writer = _writerFactory.newMarkupWriter();

            _pageLinkHandler.handle(invocation, new PageRenderer()
            {

                public void renderPage(Page page)
                {
                    _renderer.renderPageMarkup(page, writer);
                }

            });

            return writer.getDocument();
        }
        finally
        {
            _registry.cleanupThread();
        }
View Full Code Here

    public void renderPageResponse(Page page, Response response) throws IOException
    {
        // Eventually we'll have to do work to figure out the correct markup type, content type,
        // whatever. Right now its defaulting to plain HTML.

        MarkupWriter writer = _markupWriterFactory.newMarkupWriter();

        _markupRenderer.renderPageMarkup(page, writer);

        PrintWriter pw = response.getPrintWriter("text/html");

        writer.toMarkup(pw);

        pw.flush();
    }
View Full Code Here

        String charset = pageContentType.getParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER);

        ContentType contentType = new ContentType("text/javascript");
        contentType.setParameter(InternalConstants.CHARSET_CONTENT_TYPE_PARAMETER, charset);

        MarkupWriter writer = _factory.newMarkupWriter(pageContentType);

        JSONObject reply = new JSONObject();

        // ... and here, the pipeline eventually reaches the PRQ to let it render the root render command.
View Full Code Here

public class MarkupWriterImplTest extends InternalBaseTestCase
{
    @Test(expectedExceptions = IllegalStateException.class)
    public void write_with_no_current_element()
    {
        MarkupWriter w = new MarkupWriterImpl();

        w.write("fail!");
    }
View Full Code Here

    }

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

        w.write("  ");

        w.element("root");
        w.end();

        assertEquals(w.toString(), "<?xml version=\"1.0\"?>\n<root/>");
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.MarkupWriter

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.