Package org.apache.tapestry.internal.event

Examples of org.apache.tapestry.internal.event.IComponentEventInvoker


   
    public void test_Form_Render_Deffered()
    {
        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);
       
View Full Code Here


   
   
    public void test_Script_Resource()
    {  
        ClassResolver resolver = new DefaultClassResolver();
        IComponentEventInvoker invoker = new org.apache.tapestry.internal.event.impl.ComponentEventInvoker();
       
        String compScript = "/org/apache/tapestry/ComponentEvent.script";
        String widScript = "/org/apache/tapestry/dojo/html/WidgetEvent.script";
        String elementScript = "/org/apache/tapestry/html/ElementEvent.script";
       
View Full Code Here

   
    public void test_Prerendered_Field()
    {  
        ClassResolver resolver = new DefaultClassResolver();
       
        IComponentEventInvoker invoker = new org.apache.tapestry.internal.event.impl.ComponentEventInvoker();
        IEngineService engine = newMock(IEngineService.class);
        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);
        worker.setScriptSource(scriptSource);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IComponentSpecification spec = new ComponentSpecification();
       
        // now test render
        invoker.addEventListener("comp1", spec);
        spec.addEventListener("comp1", new String[] {"onclick"}, "testMethod", "form1", false, false, false, false);
       
        expect(cycle.isRewinding()).andReturn(false);
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
View Full Code Here

{
    public void test_Event_Render_Chain()
    {  
        ClassResolver resolver = new DefaultClassResolver();
       
        IComponentEventInvoker invoker = new ComponentEventInvoker();
        IEngineService engine = newMock(IEngineService.class);
        IRequestCycle cycle = newCycle();
        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();
View Full Code Here

    }
   
   
    public void test_Deferred_Connection()
    {
        IComponentEventInvoker invoker = new org.apache.tapestry.internal.event.impl.ComponentEventInvoker();
        IEngineService engine = newMock(IEngineService.class);
        IRequestCycle cycle = newCycle();
        PageRenderSupport prs = newPageRenderSupport();
       
        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setEventInvoker(invoker);
        worker.setEventEngine(engine);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IComponentSpecification spec = new ComponentSpecification();
       
        IDirectEvent comp1 = newMock(IDirectEvent.class);
        IComponentSpecification comp1Spec = new ComponentSpecification();
       
        IDirectEvent comp2 = newMock(IDirectEvent.class);
        IComponentSpecification comp2Spec = new ComponentSpecification();
       
        // now test render
        spec.addEventListener("comp1", new String[] {"onclick", "onchange"}, "testMethod", "form1", true, true, false, false);
        invoker.addEventListener("comp1", spec);
        invoker.addFormEventListener("form1", spec);
       
        spec.addEventListener("comp2", new String[] {"onclick"}, "testAnotherMethod", "form1", true, true, false, false);
        invoker.addEventListener("comp2", spec);
        invoker.addFormEventListener("form1", spec);
       
        // render of comp1
       
        expect(cycle.isRewinding()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
View Full Code Here

    {
        IComponentSpecification spec = new ComponentSpecification();
        spec.addEventListener("comp1", new String[] {"onClick"}, "testFoo", null, false, false, false, false);

        IComponent comp = newComponent(spec, "comp1", "path/");
        IComponentEventInvoker invoker = newMock(IComponentEventInvoker.class);

        invoker.addEventListener("path/comp1", spec);

        replay();

        EventConnectionVisitor v = new EventConnectionVisitor();
        v.setEventInvoker(invoker);
View Full Code Here

        spec.addElementEventListener("elem1", new String[] {"onClick"}, "testFoo", "form", false, false, false);

        IComponent comp = newComponent(spec);
        IPage page = newMock(IPage.class);
        IForm form = newMock(IForm.class);
        IComponentEventInvoker invoker = newMock(IComponentEventInvoker.class);

        Map comps = new HashMap();
        comps.put("form", form);

        expect(comp.getPage()).andReturn(page).anyTimes();
        expect(page.getComponents()).andReturn(comps).anyTimes();
        expect(comp.getComponents()).andReturn(Collections.EMPTY_MAP).anyTimes();
        expect(form.getComponents()).andReturn(Collections.EMPTY_MAP).anyTimes();

        expect(form.getId()).andReturn("form").anyTimes();
        expect(form.getExtendedId()).andReturn("path/form").anyTimes();

        invoker.addFormEventListener("path/form", spec);
        invoker.addFormEventListener("path/form", spec);

        replay();

        EventConnectionVisitor v = new EventConnectionVisitor();
        v.setEventInvoker(invoker);
View Full Code Here

    }

    public void test_Spec_Rewire_Id()
    {
        IComponentSpecification spec = newMock(IComponentSpecification.class);
        IComponentEventInvoker invoker = newMock(IComponentEventInvoker.class);
        IComponent comp = newComponent(spec, "comp1", "path/");

        ComponentEventProperty p = new ComponentEventProperty("comp1");
        p.addListener(new String[] {"onClick"}, "testFoo", null, false, false, false, false);

        Map compEvents = new HashMap();
        compEvents.put("comp1", p);
       
        expect(spec.getComponentEvents()).andReturn(compEvents);
        expect(spec.getElementEvents()).andReturn(Collections.EMPTY_MAP);

        invoker.addEventListener("path/comp1", spec);
        spec.rewireComponentId("comp1", "path/comp1");

        replay();

        EventConnectionVisitor v = new EventConnectionVisitor();
View Full Code Here

    {
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();
        Resource resource = newResource(AnnotatedPage.class);
       
        IComponentEventInvoker invoker = new ComponentEventInvoker();
       
        EventListenerAnnotationWorker worker = new EventListenerAnnotationWorker();
        worker.setInvoker(invoker);
       
        replay();
       
        Method m = findMethod(AnnotatedPage.class, "eventListener");
       
        assertTrue(worker.canEnhance(m));
        assertFalse(worker.canEnhance(findMethod(AnnotatedPage.class, "getPersistentProperty")));
        worker.peformEnhancement(op, spec, m, resource);
       
        verify();
       
        assertEquals(1, invoker.getEventListeners("email").size());
       
        ComponentEventProperty property = spec.getComponentEvents("email");
        assertNotNull(property);
       
        List listeners = property.getEventListeners("onClick");
View Full Code Here

    public void test_Form_Event_Connection()
    {
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();
        Resource resource = newResource(AnnotatedPage.class);
        IComponentEventInvoker invoker = new ComponentEventInvoker();
       
        EventListenerAnnotationWorker worker = new EventListenerAnnotationWorker();
        worker.setInvoker(invoker);
       
        replay();
       
        Method m = findMethod(AnnotatedPage.class, "formListener");
       
        assertTrue(worker.canEnhance(m));
        worker.peformEnhancement(op, spec, m, resource);
       
        verify();
       
        assertEquals(1, invoker.getEventListeners("email").size());
        assertEquals(1, invoker.getFormEventListeners("testForm").size());
       
        ComponentEventProperty property = spec.getComponentEvents("email");
        assertNotNull(property);
       
        List listeners = property.getFormEventListeners("onClick");
View Full Code Here

TOP

Related Classes of org.apache.tapestry.internal.event.IComponentEventInvoker

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.