Package org.apache.tapestry

Examples of org.apache.tapestry.NestedMarkupWriter


    public void testRenderExtraReservedIds()
    {
        MockControl writerc = newControl(IMarkupWriter.class);
        IMarkupWriter writer = (IMarkupWriter) writerc.getMock();

        NestedMarkupWriter nested = newNestedWriter();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockForm form = new MockForm();

        cycle.isRewound(form);
        cyclec.setReturnValue(false);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        final IFormComponent component = newFormComponent("action", "action$0");

        IRender body = newComponentRenderBody(fs, component, nested);

        form.setBody(body);

        MockControl linkc = newControl(ILink.class);
        ILink link = (ILink) linkc.getMock();

        IRender render = (IRender) newMock(IRender.class);

        link.getParameterNames();
        linkc.setReturnValue(new String[]
        { "action" });

        link.getParameterValues("action");
        linkc.setReturnValue(new String[]
        { "fred" });

        writer.getNestedWriter();
        writerc.setReturnValue(nested);

        link.getURL(null, false);
        linkc.setReturnValue("/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");

        render.render(writer, cycle);

        writer.println();

        trainHidden(writer, "formids", "action$0");
        trainHidden(writer, "action", "fred");
        trainHidden(writer, "reservedids", "action");

        nested.close();

        writer.end();

        replayControls();
View Full Code Here


    public void testResetEventHandler()
    {
        MockControl writerc = newControl(IMarkupWriter.class);
        IMarkupWriter writer = (IMarkupWriter) writerc.getMock();

        NestedMarkupWriter nested = newNestedWriter();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockForm form = new MockForm();

        cycle.isRewound(form);
        cyclec.setReturnValue(false);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        form.setBody(new IRender()
        {
            public void render(IMarkupWriter writer, IRequestCycle cycle)
            {
                fs.addEventHandler(FormEventType.RESET, "myReset1");
                fs.addEventHandler(FormEventType.RESET, "myReset2");
            }
        });

        MockControl linkc = newControl(ILink.class);
        ILink link = (ILink) linkc.getMock();

        IRender render = (IRender) newMock(IRender.class);

        link.getParameterNames();
        linkc.setReturnValue(new String[]
        { "service" });

        link.getParameterValues("service");
        linkc.setReturnValue(new String[]
        { "fred" });

        writer.getNestedWriter();
        writerc.setReturnValue(nested);

        link.getURL(null, false);
        linkc.setReturnValue("/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");

        render.render(writer, cycle);

        writer.println();

        trainHidden(writer, "formids", "");
        trainHidden(writer, "service", "fred");

        nested.close();

        writer.end();

        trainForPageSupport(
                cyclec,
View Full Code Here

    public void testSimpleRender()
    {
        MockControl writerc = newControl(IMarkupWriter.class);
        IMarkupWriter writer = (IMarkupWriter) writerc.getMock();

        NestedMarkupWriter nested = newNestedWriter();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockForm form = new MockForm();

        cycle.isRewound(form);
        cyclec.setReturnValue(false);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        final IFormComponent component = newFormComponent("barney", "barney");

        IRender body = newComponentRenderBody(fs, component, nested);

        form.setBody(body);

        MockControl linkc = newControl(ILink.class);
        ILink link = (ILink) linkc.getMock();

        IRender render = (IRender) newMock(IRender.class);

        link.getParameterNames();
        linkc.setReturnValue(new String[]
        { "service" });

        link.getParameterValues("service");
        linkc.setReturnValue(new String[]
        { "fred" });

        writer.getNestedWriter();
        writerc.setReturnValue(nested);

        link.getURL(null, false);
        linkc.setReturnValue("/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");

        render.render(writer, cycle);

        writer.println();

        trainHidden(writer, "formids", "barney");
        trainHidden(writer, "service", "fred");

        nested.close();

        writer.end();

        replayControls();
View Full Code Here

    public void testSimpleSubmitEventHandler()
    {
        MockControl writerc = newControl(IMarkupWriter.class);
        IMarkupWriter writer = (IMarkupWriter) writerc.getMock();

        NestedMarkupWriter nested = newNestedWriter();

        MockControl cyclec = newControl(IRequestCycle.class);
        IRequestCycle cycle = (IRequestCycle) cyclec.getMock();

        MockForm form = new MockForm();

        cycle.isRewound(form);
        cyclec.setReturnValue(false);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        form.setBody(new IRender()
        {
            public void render(IMarkupWriter writer, IRequestCycle cycle)
            {
                fs.addEventHandler(FormEventType.SUBMIT, "mySubmit");
            }
        });

        MockControl linkc = newControl(ILink.class);
        ILink link = (ILink) linkc.getMock();

        IRender render = (IRender) newMock(IRender.class);

        link.getParameterNames();
        linkc.setReturnValue(new String[]
        { "service" });

        link.getParameterValues("service");
        linkc.setReturnValue(new String[]
        { "fred" });

        writer.getNestedWriter();
        writerc.setReturnValue(nested);

        link.getURL(null, false);
        linkc.setReturnValue("/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");

        render.render(writer, cycle);

        writer.println();

        trainHidden(writer, "formids", "");
        trainHidden(writer, "service", "fred");

        nested.close();

        writer.end();

        trainForPageSupport(cyclec, cycle, "document.myform.onsubmit = mySubmit;\n");
View Full Code Here

        if (_prerenderMap.containsKey(key))
            throw new ApplicationRuntimeException(FormMessages.fieldAlreadyPrerendered(field),
                    location, null);

        NestedMarkupWriter nested = writer.getNestedWriter();

        field.render(nested, _cycle);

        _prerenderMap.put(key, nested.getBuffer());
    }
View Full Code Here

    }

    public void testComplexRender()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine(getClassResolver());
        IValidationDelegate delegate = newDelegate();
        ILink link = newLink();
        IRender render = newRender();

        MockForm form = new MockForm(delegate);

        trainIsRewound(cycle, form, false);

        trainGetEngine(cycle, engine);

        PageRenderSupport support = newPageRenderSupport();

        trainGetPageRenderSupport(cycle, support);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        final IFormComponent barney1 = newFormComponent("barney", "barney");
        final IFormComponent wilma = newFormComponent("wilma", "wilma");
        final IFormComponent barney2 = newFormComponent("barney", "barney_0");

        IRender body = newComponentsRenderBody(fs, new IFormComponent[]
        { barney1, wilma, barney2 }, nested);

        form.setBody(body);

        trainRegister(support);

        trainGetParameterNames(link, new String[]
        { "service" });
        trainGetParameterValues(link, "service", new String[]
        { "fred" });

        trainGetNestedWriter(writer, nested);

        trainGetURL(link, null, "/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");
        writer.attribute("id", "myform");

        render.render(writer, cycle);

        writer.println();

        trainDiv(writer);

        trainHidden(writer, "formids", "barney,wilma,barney_0");
        trainHidden(writer, "service", "fred");
        trainHidden(writer, "submitmode", "");

        writer.end();

        nested.close();

        writer.end();

        trainGetFocusField(delegate, "wilma");
        trainGetFieldFocus(cycle, null);
View Full Code Here

    }

    public void testComplexSubmitEventHandler()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine(getClassResolver());
        IValidationDelegate delegate = newDelegate();
        PageRenderSupport support = newPageRenderSupport();
        ILink link = newLink();
        IRender render = newRender();

        MockForm form = new MockForm(delegate);

        trainIsRewound(cycle, form, false);
        trainGetEngine(cycle, engine);
        trainGetPageRenderSupport(cycle, support);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        form.setBody(new IRender()
        {
            public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
            {
                fs.addEventHandler(FormEventType.SUBMIT, "mySubmit1");
                fs.addEventHandler(FormEventType.SUBMIT, "mySubmit2");
                fs.addEventHandler(FormEventType.SUBMIT, "mySubmit3");
            }
        });

        trainRegister(support);

        trainGetParameterNames(link, new String[]
        { "service" });

        trainGetParameterValues(link, "service", new String[]
        { "fred" });

        trainGetNestedWriter(writer, nested);

        trainGetURL(link, null, "/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");
        writer.attribute("id", "myform");

        render.render(writer, cycle);

        writer.println();

        trainDiv(writer);

        trainHidden(writer, "formids", "");
        trainHidden(writer, "service", "fred");
        trainHidden(writer, "submitmode", "");

        writer.end();

        nested.close();

        writer.end();

        support
                .addInitializationScript("Tapestry.onsubmit('myform', function (event)\n{\n  mySubmit1();\n  mySubmit2();\n  mySubmit3();\n});\n");
View Full Code Here

    }

    public void testEncodingType()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine(getClassResolver());
        IValidationDelegate delegate = newDelegate();
        PageRenderSupport support = newPageRenderSupport();
        ILink link = newLink();
        IRender render = newRender();

        MockForm form = new MockForm(delegate);

        trainIsRewound(cycle, form, false);
        trainGetEngine(cycle, engine);

        trainGetPageRenderSupport(cycle, support);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        form.setBody(new IRender()
        {
            public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
            {
                fs.setEncodingType("foo/bar");
            }
        });

        trainRegister(support);

        trainGetParameterNames(link, new String[]
        { "service" });

        trainGetParameterValues(link, "service", new String[]
        { "fred" });

        trainGetNestedWriter(writer, nested);

        trainGetURL(link, null, "/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");
        writer.attribute("name", "myform");
        writer.attribute("id", "myform");
        writer.attribute("enctype", "foo/bar");

        render.render(writer, cycle);

        writer.println();

        trainDiv(writer);

        trainHidden(writer, "formids", "");
        trainHidden(writer, "service", "fred");
        trainHidden(writer, "submitmode", "");

        writer.end();

        nested.close();

        writer.end();

        trainGetFocusField(delegate, null);
View Full Code Here

    }

    public void testHiddenValues()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine(getClassResolver());
        IValidationDelegate delegate = newDelegate();
        PageRenderSupport support = newPageRenderSupport();
        ILink link = newLink();
        IRender render = newRender();

        MockForm form = new MockForm(delegate);

        trainIsRewound(cycle, form, false);

        trainGetEngine(cycle, engine);

        trainGetPageRenderSupport(cycle, support);

        replayControls();

        final FormSupport fs = new FormSupportImpl(writer, cycle, form);

        verifyControls();

        form.setBody(new IRender()
        {
            public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
            {
                fs.addHiddenValue("hidden1", "value1");
                fs.addHiddenValue("hidden2", "id2", "value2");
            }
        });

        trainRegister(support);

        trainGetParameterNames(link, new String[]
        { "service" });

        trainGetParameterValues(link, "service", new String[]
        { "fred" });

        trainGetNestedWriter(writer, nested);

        trainGetURL(link, null, "/app");

        writer.begin("form");
        writer.attribute("method", "post");
        writer.attribute("action", "/app");

        writer.attribute("name", "myform");
        writer.attribute("id", "myform");

        render.render(writer, cycle);

        writer.println();

        trainDiv(writer);

        trainHidden(writer, "formids", "");
        trainHidden(writer, "service", "fred");
        trainHidden(writer, "submitmode", "");
        trainHidden(writer, "hidden1", "value1");
        trainHidden(writer, "hidden2", "id2", "value2");

        writer.end();

        nested.close();

        writer.end();

        trainGetFocusField(delegate, null);
View Full Code Here

    }

    public void testInvalidEncodingType()
    {
        IMarkupWriter writer = newWriter();
        NestedMarkupWriter nested = newNestedWriter();
        IRequestCycle cycle = newCycle();
        IEngine engine = newEngine(getClassResolver());
        IValidationDelegate delegate = newDelegate();
        PageRenderSupport support = newPageRenderSupport();
        ILink link = newLink();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.NestedMarkupWriter

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.