Package org.apache.tapestry

Examples of org.apache.tapestry.MarkupWriter


    @Test
    public void output_with_element_and_informals()
    {
        String elementName = "span";

        MarkupWriter writer = createMarkupWriter();

        ComponentResources resources = mockComponentResources();

        train_renderInformalParameters(resources, writer, "foo", "bar");

        replay();

        Output component = new Output();

        component.setup(_value, _format, elementName, resources);

        assertFalse(component.beginRender(writer));

        verify();

        assertEquals(writer.toString(), "<span foo=\"bar\">22.70</span>");
    }
View Full Code Here


    @Test
    public void null_format_is_a_noop()
    {
        String elementName = "span";

        MarkupWriter writer = createMarkupWriter();

        ComponentResources resources = mockComponentResources();

        Format format = new Format()
        {
            @Override
            public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
            {
                return toAppendTo;
            }

            @Override
            public Object parseObject(String source, ParsePosition pos)
            {
                return null;
            }
        };

        replay();

        Output component = new Output();

        component.setup(_value, format, elementName, resources);

        writer.element("root");
        assertFalse(component.beginRender(writer));
        writer.end();

        verify();

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

public class PageLinkTest extends TapestryTestCase
{
    @Test
    public void no_output_when_disabled()
    {
        MarkupWriter writer = mockMarkupWriter();

        PageLink component = new PageLink();
       
        component.setDisabled(true);
View Full Code Here

                queue.push(command2);
            }
        };

        Log log = mockLog();
        MarkupWriter writer = mockMarkupWriter();
        RenderQueueImpl queue = new RenderQueueImpl(log);

        expect(log.isDebugEnabled()).andReturn(false).atLeastOnce();

        command2.render(writer, queue);
View Full Code Here

                return "FailedCommand";
            }
        };

        Log log = mockLog();
        MarkupWriter writer = mockMarkupWriter();

        expect(log.isDebugEnabled()).andReturn(false).atLeastOnce();

        log.error("Render queue error in FailedCommand: Oops.", t);
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

    private final Format _format = new DecimalFormat("0.00");

    @Test
    public void simple_output()
    {
        MarkupWriter writer = createMarkupWriter();
        ComponentResources resources = newComponentResources();

        replay();

        Output component = new Output();

        component.setup(_value, _format, null, resources);

        writer.element("root");
        assertFalse(component.beginRender(writer));
        writer.end();

        verify();

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

    @Test
    public void output_with_element_and_informals()
    {
        String elementName = "span";

        MarkupWriter writer = createMarkupWriter();

        ComponentResources resources = newComponentResources();

        train_renderInformalParameters(resources, writer, "foo", "bar");

        replay();

        Output component = new Output();

        component.setup(_value, _format, elementName, resources);

        assertFalse(component.beginRender(writer));

        verify();

        assertEquals(writer.toString(), "<span foo=\"bar\">22.70</span>");
    }
View Full Code Here

    @Test
    public void null_format_is_a_noop()
    {
        String elementName = "span";

        MarkupWriter writer = createMarkupWriter();

        ComponentResources resources = newComponentResources();

        Format format = new Format()
        {
            @Override
            public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
            {
                return toAppendTo;
            }

            @Override
            public Object parseObject(String source, ParsePosition pos)
            {
                return null;
            }
        };

        replay();

        Output component = new Output();

        component.setup(_value, format, elementName, resources);

        writer.element("root");
        assertFalse(component.beginRender(writer));
        writer.end();

        verify();

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

        Select select = new Select();

        select.setModel(new SelectModelImpl(null, options));
        select.setValue("barney");

        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);

        writer.element("select");

        select.options(writer);

        writer.end();

        assertEquals(writer.toString(), read("just_options.html"));
    }
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.