Examples of IScriptSource


Examples of org.apache.tapestry.engine.IScriptSource

    protected void processValidatorScript(String scriptPath, IRequestCycle cycle,
            IFormComponent field, Map symbols)
    {
        IEngine engine = field.getPage().getEngine();
        IScriptSource source = engine.getScriptSource();
        IForm form = field.getForm();

        Map finalSymbols = (symbols == null) ? new HashMap() : symbols;

        finalSymbols.put(FIELD_SYMBOL, field);
        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
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

    {
        EnhancementOperation op = newMock(EnhancementOperation.class);

        final Location injectSpecLocation = newLocation();

        final IScriptSource source = newMock(IScriptSource.class);
       
        // Location componentSpecLocation = newLocation();
        Resource scriptResource = newResource();

        op.claimReadonlyProperty("foo");
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

        checkOrder(cycle, false);
       
        IComponentSpecification spec = new ComponentSpecification();
        IComponentSpecification widgetSpec = new ComponentSpecification();
       
        IScriptSource scriptSource = newMock(IScriptSource.class);
        IScript script = newMock(IScript.class);
       
        PageRenderSupport prs = newPageRenderSupport();
       
        ILink link = newMock(ILink.class);
       
        String elemScript = "/org/apache/tapestry/html/ElementEvent.script";
        String compScript = "/org/apache/tapestry/ComponentEvent.script";
        String widScript = "/org/apache/tapestry/dojo/html/WidgetEvent.script";
       
        Resource compScriptResource = new ClasspathResource(resolver, compScript);
        Resource widScriptResource = new ClasspathResource(resolver, widScript);
        Resource elemScriptResource = new ClasspathResource(resolver, elemScript);
       
        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setClassResolver(resolver);
        worker.setEventInvoker(invoker);
        worker.setComponentScript(compScript);
        worker.setWidgetScript(widScript);
        worker.setElementScript(elemScript);
        worker.setEventEngine(engine);
        worker.setScriptSource(scriptSource);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IWidget widget = newMock(IWidget.class);
       
        assertNotNull(worker.getScript(component));
        assertEquals(compScript, worker.getScript(component).getPath());
       
        assertNotNull(worker.getScript(widget));
        assertEquals(widScript, worker.getScript(widget).getPath());
       
        assertNotNull(worker.getElementScript());
        assertEquals(elemScript, worker.getElementScript().getPath());
       
        // now test render
        invoker.addEventListener("comp1", spec);
        spec.addEventListener("comp1", new String[] {"onclick"}, "testMethod", null, false, true, false, false);
        spec.addElementEventListener("elementId", new String[] {"onclick"}, "testMethod", null, false, true, false);
       
        /////////////////////////////////
       
        Map elmEvents = spec.getElementEvents();
        Iterator keyIt = elmEvents.keySet().iterator();
       
        while (keyIt.hasNext()) {
            String elem = (String)keyIt.next();
            assertEquals(elem, "elementId");
           
            ComponentEventProperty prop = (ComponentEventProperty)elmEvents.get(elem);
            assertNotNull(prop);
           
            Object[][] events = worker.getEvents(prop, elem);
           
            assertNotNull(events);
            assertEquals(events.length, 1);
            assertEquals(events[0].length, 2);
        }
       
        ////////////////////////////////////////////
       
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(component.getExtendedId()).andReturn("comp1").anyTimes();
        expect(component.getClientId()).andReturn("comp1").anyTimes();
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs).anyTimes();
        expect(component.getSpecification()).andReturn(spec);
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
        trainGetURL(link, "/some/url");
       
        expect(scriptSource.getScript(compScriptResource)).andReturn(script);
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        expect(component.getSpecification()).andReturn(spec);
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
        trainGetURL(link, "/some/url");
       
        expect(scriptSource.getScript(elemScriptResource)).andReturn(script);
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        worker.renderComponent(cycle, component);
       
        verify();
       
        assertEquals(0, worker.getDefferedFormConnections().size());
       
        // test widget render
       
        invoker.addEventListener("wid1", widgetSpec);
        widgetSpec.addEventListener("wid1", new String[] {"onclick"}, "testMethod", null, false, true, false, false);
       
        checkOrder(cycle, false);
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs).anyTimes();
       
        expect(widget.getSpecification()).andReturn(widgetSpec);
       
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(widget.getExtendedId()).andReturn("wid1").anyTimes();
        expect(widget.getClientId()).andReturn("wid1").anyTimes();
       
        assert widgetSpec.getComponentEvents("wid1") != null;
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
        trainGetURL(link, "/some/url2");
       
        expect(scriptSource.getScript(widScriptResource)).andReturn(script);
       
        script.execute(eq(widget), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

        ClassResolver resolver = new DefaultClassResolver();
       
        IComponentEventInvoker invoker = new ComponentEventInvoker();
        IEngineService engine = newMock(IEngineService.class);
        IRequestCycle cycle = newCycle();
        IScriptSource scriptSource = newMock(IScriptSource.class);
        IScript script = newMock(IScript.class);
       
        PageRenderSupport prs = newPageRenderSupport();
       
        String compScript = "/org/apache/tapestry/ComponentEvent.script";
        Resource compScriptResource = new ClasspathResource(resolver, compScript);
       
        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setClassResolver(resolver);
        worker.setEventInvoker(invoker);
        worker.setComponentScript(compScript);
        worker.setEventEngine(engine);
        worker.setScriptSource(scriptSource);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IComponentSpecification spec = new ComponentSpecification();
       
        IComponent comp1 = newMock(IComponent.class);
        IComponentSpecification comp1Spec = new ComponentSpecification();
       
        IComponent comp2 = newMock(IComponent.class);
        IComponentSpecification comp2Spec = new ComponentSpecification();
       
        IForm form = newMock(IForm.class);
        IComponentSpecification formSpec = new ComponentSpecification();
       
        // now test render
        spec.addEventListener("comp1", new String[] {"onclick"}, "testMethod", "form1", false, true, false, false);
        invoker.addEventListener("comp1", spec);
        invoker.addFormEventListener("form1", spec);
       
        spec.addEventListener("comp2", new String[] {"ondoubleclick"}, "clickMethod", "form1", false, true, false, false);
        invoker.addEventListener("comp2", spec);
        invoker.addFormEventListener("form1", spec);
       
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(component.getExtendedId()).andReturn("compListener").anyTimes();
        expect(component.getClientId()).andReturn("compListener").anyTimes();
        expect(component.getSpecification()).andReturn(spec);
       
        // comp1 render
       
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(comp1.getExtendedId()).andReturn("comp1").anyTimes();
        expect(comp1.getClientId()).andReturn("comp1").anyTimes();
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
       
        expect(comp1.getSpecification()).andReturn(comp1Spec).anyTimes();
       
        // comp2 render
       
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(comp2.getExtendedId()).andReturn("comp2").anyTimes();
        expect(comp2.getClientId()).andReturn("comp2").anyTimes();
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
       
        expect(comp2.getSpecification()).andReturn(comp2Spec).anyTimes();
       
        replay();
       
        worker.renderComponent(cycle, component);
        worker.renderComponent(cycle, comp1);
        worker.renderComponent(cycle, comp2);
       
        verify();
       
        assertEquals(worker.getDefferedFormConnections().size(), 1);
        assertEquals(((List)worker.getDefferedFormConnections().get("form1")).size(), 2);
       
        checkOrder(form, false);
        checkOrder(component, false);
        checkOrder(comp1, false);
        checkOrder(comp2, false);
       
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
       
        expect(form.getSpecification()).andReturn(formSpec);
       
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(form.getExtendedId()).andReturn("form1").anyTimes();
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
        cycle.setAttribute(eq(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1"), isA(List.class));
       
        expect(form.getName()).andReturn("form1_0").anyTimes();

        expect(comp1.getSpecification()).andReturn(comp1Spec);
        expect(comp1.getExtendedId()).andReturn("comp1").anyTimes();
       
        expect(comp2.getSpecification()).andReturn(comp2Spec);
        expect(comp2.getExtendedId()).andReturn("comp2").anyTimes();
       
        List formNames = new ArrayList();
        formNames.add("form1_0");
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(formNames).anyTimes();
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs).anyTimes();
       
        expect(scriptSource.getScript(compScriptResource)).andReturn(script);
        script.execute(eq(form), eq(cycle), eq(prs), isA(Map.class));
       
        expect(scriptSource.getScript(compScriptResource)).andReturn(script);
        script.execute(eq(form), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        worker.renderComponent(cycle, form);
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

        IRequestCycle cycle = newCycle();
        checkOrder(cycle, false);
       
        PageRenderSupport prs = newPageRenderSupport();
       
        IScriptSource scriptSource = newMock(IScriptSource.class);
       
        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setClassResolver(resolver);
        worker.setEventInvoker(invoker);
        worker.setEventEngine(engine);
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

    private IScript getParsedScript()
    {
        if (_parsedScript == null)
        {
            IEngine engine = getPage().getEngine();
            IScriptSource source = engine.getScriptSource();

            IResourceLocation scriptLocation =
                getSpecification().getSpecificationLocation().getRelativeLocation(
                    "Rollover.script");

            _parsedScript = source.getScript(scriptLocation);
        }

        return _parsedScript;
    }
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

        IRequestCycle cycle,
        IFormComponent field,
        Map symbols)
    {
        IEngine engine = field.getPage().getEngine();
        IScriptSource source = engine.getScriptSource();
        IForm form = field.getForm();

        Map finalSymbols = (symbols == null) ? new HashMap() : symbols;

        finalSymbols.put(FIELD_SYMBOL, field);
        finalSymbols.put(FORM_SYMBOL, form);
        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(
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

        if (scriptPath == null)
            throw Tapestry.createRequiredParameterException(this, "scriptPath");

        IEngine engine = cycle.getEngine();
        IScriptSource source = engine.getScriptSource();

        // If the script path is relative, it should be relative to the Script component's
        // container (i.e., relative to a page in the application).

        IResourceLocation rootLocation =
            getContainer().getSpecification().getSpecificationLocation();
        IResourceLocation scriptLocation = rootLocation.getRelativeLocation(scriptPath);

        try
        {
            return source.getScript(scriptLocation);
        }
        catch (RuntimeException ex)
        {
            throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex);
        }
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

        final Resource scriptResource = componentSpecLocation.getResource().getRelativeResource(
                "bar.script");

        final Location injectSpecLocation = newLocation();

        final IScriptSource source = (IScriptSource) newMock(IScriptSource.class);

        op.claimProperty("foo");

        op.getPropertyType("foo");
        opc.setReturnValue(IScript.class);
View Full Code Here

Examples of org.apache.tapestry.engine.IScriptSource

    protected void processValidatorScript(String scriptPath, IRequestCycle cycle,
            IFormComponent field, Map symbols)
    {
        IEngine engine = field.getPage().getEngine();
        IScriptSource source = engine.getScriptSource();
        IForm form = field.getForm();

        Map finalSymbols = (symbols == null) ? new HashMap() : symbols;

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

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

        IScript script = source.getScript(location);

        // If there's an error, report it against the field (this validator object doesn't
        // have a location).

        PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, field);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.