Package org.apache.tapestry

Examples of org.apache.tapestry.PageRenderSupport


    /**
     * Executes the associated script, which generates all the JavaScript to support this Palette.
     */
    private void runScript(IRequestCycle cycle)
    {
        PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);

        setImage(pageRenderSupport, cycle, "selectImage", getSelectImage());
        setImage(pageRenderSupport, cycle, "selectDisabledImage", getSelectDisabledImage());
        setImage(pageRenderSupport, cycle, "deselectImage", getDeselectImage());
        setImage(pageRenderSupport, cycle, "deselectDisabledImage", getDeselectDisabledImage());
View Full Code Here


        String anchor = component.getAnchor();
        ILink link = component.getLink(cycle);

        String url = link.getURL(anchor, true);

        PageRenderSupport support = TapestryUtils.getPageRenderSupport(cycle, component);

        String functionName = support.getUniqueString("popup_window");

        BodyBuilder builder = new BodyBuilder();

        builder.addln("{0}=function()", functionName);
        builder.begin();
        builder.add(
                "var newWindow = window.open({0}, {1}, {2});",
                TapestryUtils.enquote(url),
                TapestryUtils.enquote(getWindowName()),
                TapestryUtils.enquote(getFeatures()));
        builder.add("newWindow.focus();");
        builder.end();
        builder.addln(";");

        support.addBodyScript(component, builder.toString());

        return "javascript:" + functionName + "();";
    }
View Full Code Here

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, 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);

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

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

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

        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,wilma,barney$0");
        trainHidden(writer, "service", "fred");
        trainHidden(writer, "submitmode", "");

        nested.close();

        writer.end();

        trainGetFocusField(delegatec, delegate, "wilma");
        trainGetFieldFocus(cyclec, cycle, null);

        support.addInitializationScript("focus(document.myform.wilma);");

        trainSetFieldFocus(cycle);

        replayControls();
View Full Code Here

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        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, "mySubmit1");
                fs.addEventHandler(FormEventType.SUBMIT, "mySubmit2");
                fs.addEventHandler(FormEventType.SUBMIT, "mySubmit3");
            }
        });

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

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

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

        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");
        trainHidden(writer, "submitmode", "");

        nested.close();

        writer.end();

        support
                .addInitializationScript("myform_events.addSubmitListener(function (event)\n{\n  mySubmit1();\n  mySubmit2();\n  mySubmit3();\n});\n");

        // Side test: what if no focus field?

        trainGetFocusField(delegatec, delegate, null);
View Full Code Here

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        replayControls();

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

        verifyControls();

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

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

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

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

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

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        replayControls();

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

        verifyControls();

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

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

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

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

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

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        replayControls();

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

        verifyControls();

        form.setBody(new IRender()
        {
            public void render(IMarkupWriter writer, IRequestCycle cycle)
            {
                fs.setEncodingType("foo/bar");
                fs.setEncodingType("zip/zap");
            }
        });

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

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

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

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

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        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);

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

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

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        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);

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

        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");
        trainHidden(writer, "submitmode", "");

        nested.close();

        writer.end();

        support
                .addInitializationScript("myform_events.addResetListener(function (event)\n{\n  myReset1();\n  myReset2();\n});\n");

        trainGetFocusField(delegatec, delegate, null);

        replayControls();
View Full Code Here

        engine.getClassResolver();
        enginec.setReturnValue(getClassResolver());

        MockControl supportc = newControl(PageRenderSupport.class);
        PageRenderSupport support = (PageRenderSupport) supportc.getMock();

        trainGetPageRenderSupport(cyclec, cycle, support);

        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);

        support.addExternalScript(new ClasspathResource(getClassResolver(),
                "/org/apache/tapestry/form/Form.js"));

        support
                .addInitializationScript("var myform_events = new FormEventManager(document.myform);");

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

TOP

Related Classes of org.apache.tapestry.PageRenderSupport

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.