Package org.apache.tapestry

Examples of org.apache.tapestry.IScript


        assertSymbol(symbols, "gamma", "Alpha$1");
    }

    public void testIncludeScript() throws Exception
    {
        IScript script = execute("include-script.script", null);

        Resource scriptLocation = script.getScriptResource();

        Resource[] expected = new Resource[]
        { scriptLocation.getRelativeResource("first"),
                scriptLocation.getRelativeResource("second"),
                scriptLocation.getRelativeResource("third") };
View Full Code Here


    /**
     * A bunch of quickies to push up the code coverage numbers.
     */
    public void testCheats() throws Exception
    {
        IScript script = execute("simple.script", null);

        ScriptSession session = new ScriptSessionImpl(script.getScriptResource(), null, null,
                createExpressionEvaluator(), null, null);
        assertEquals("ScriptSession[" + script.getScriptResource() + "]", session.toString());
    }
View Full Code Here

        IScriptSource source = engine.getScriptSource();

        Resource scriptLocation = getSpecification().getSpecificationLocation()
                .getRelativeResource("InspectorButton.script");

        IScript script = source.getScript(scriptLocation);

        Map symbols = new HashMap();

        IEngineService service = engine.getService(Tapestry.DIRECT_SERVICE);
        ILink link = service.getLink(cycle, new DirectServiceParameter(this));

        symbols.put("URL", link.getURL());

        Body body = Body.get(cycle);

        if (body == null)
            throw new ApplicationRuntimeException(Tapestry
                    .getMessage("InspectorButton.must-be-contained-by-body"), this, null, null);

        script.execute(cycle, body, symbols);

        // Now, go render the rest from the template.

        super.renderComponent(writer, cycle);
    }
View Full Code Here

        _cache.clear();
    }

    public synchronized IScript getScript(Resource resource)
    {
        IScript result = (IScript) _cache.get(resource);

        if (result != null)
            return result;

        result = parse(resource);
View Full Code Here

        finalSymbols.put(FORM_SYMBOL, form);
        finalSymbols.put(VALIDATOR_SYMBOL, this);

        Resource location = new ClasspathResource(engine.getClassResolver(), scriptPath);

        IScript script = source.getScript(location);

        Body body = Body.get(cycle);

        if (body == null)
            throw new ApplicationRuntimeException(Tapestry
                    .getMessage("ValidField.must-be-contained-by-body"), field, null, null);

        script.execute(cycle, body, finalSymbols);

        String functionName = (String) finalSymbols.get(FUNCTION_SYMBOL);

        form.addEventHandler(FormEventType.SUBMIT, functionName);
    }
View Full Code Here

        MockDelegate delegate = new MockDelegate();
       
        IEngineService engine = newEngineService();
        ILink link = newLink();
       
        IScript script = newMock(IScript.class);
       
        SimpleBean match = new SimpleBean(new Integer(2), "Simple 2", 200);
       
        Autocompleter component = newInstance(Autocompleter.class,
                new Object[] {
            "name", "fred", "model", model,
            "directService", engine,
            "script", script,
            "validatableFieldSupport", vfs,
            "value", match,
            "dataSqueezer", ds, "local", local
        });
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        expect(form.getName()).andReturn("testform").anyTimes();
       
        form.setFormFieldUpdating(true);
       
        IMarkupWriter writer = newBufferWriter();
       
        DirectServiceParameter dsp =
            new DirectServiceParameter(component);
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
       
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
       
        delegate.setFormComponent(component);
       
        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();
       
        vfs.renderContributions(component, writer, cycle);
        if (!local.booleanValue())
        {
            trainGetLinkCheckIgnoreParameter(engine, cycle, true, dsp, link);       
            trainGetURL(link, "urlstring");
        }
        else
        {
            expect(ds.squeeze(1)).andReturn("1p");
            expect(ds.squeeze(2)).andReturn("2p");
            expect(ds.squeeze(3)).andReturn("3p");
        }
        // for the default value
        expect(ds.squeeze(2)).andReturn("2p");
       
        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        expect(cycle.renderStackPop()).andReturn(component);
       
        replay();
       
View Full Code Here

        finalSymbols.put(VALIDATOR_SYMBOL, this);

        IResourceLocation location =
            new ClasspathResourceLocation(engine.getResourceResolver(), scriptPath);

        IScript script = source.getScript(location);

        Body body = Body.get(cycle);

        if (body == null)
            throw new ApplicationRuntimeException(
                Tapestry.getMessage("ValidField.must-be-contained-by-body"),
                field,
                null,
                null);

        script.execute(cycle, body, finalSymbols);

        String functionName = (String) finalSymbols.get(FUNCTION_SYMBOL);

        form.addEventHandler(FormEventType.SUBMIT, functionName);
    }
View Full Code Here

        return parser.parse(scriptLocation);
    }

    private IScript execute(String file, Map symbols) throws DocumentParseException, IOException
    {
        IScript script = read(file);

        IRequestCycle cycle = (IRequestCycle) newMock(IRequestCycle.class);

        replayControls();

        script.execute(cycle, _processor, symbols);

        verifyControls();

        return script;
    }
View Full Code Here

     * @since 3.0
     */

    public void testUnique() throws Exception
    {
        IScript script = read("unique.script");

        IRequestCycle cycle = new RequestCycle();

        script.execute(cycle, _processor, null);
        script.execute(cycle, _processor, null);

        assertEquals("Block1\nBlock2\nNotUnique\n\n\n\nNotUnique", _processor.getBody().trim());
    }
View Full Code Here

        assertSymbol(symbols, "gamma", "Alpha$1");
    }

    public void testIncludeScript() throws Exception
    {
        IScript script = execute("include-script.script", null);

        Resource scriptLocation = script.getScriptResource();

        Resource[] expected = new Resource[]
        { scriptLocation.getRelativeResource("first"),
                scriptLocation.getRelativeResource("second"),
                scriptLocation.getRelativeResource("third") };
View Full Code Here

TOP

Related Classes of org.apache.tapestry.IScript

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.