Package org.apache.tapestry.internal.event.impl

Examples of org.apache.tapestry.internal.event.impl.ComponentEventInvoker


        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        MockForm form = new MockForm(delegate);
        ListenerInvoker listenerInvoker = newMock(ListenerInvoker.class);
       
        ComponentEventInvoker invoker = new ComponentEventInvoker();
        invoker.setInvoker(listenerInvoker);
       
        trainIsRewound(cycle, form, true);
        trainGetPageRenderSupport(cycle, null);
       
        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);
       
        verify();

        delegate.clear();
       
        trainCycleForRewind(cycle, "barney,wilma,barney_0", null);

        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 }, writer);

        form.setBody(body);
        form.setEventInvoker(invoker);
       
        trainExtractBrowserEvent(cycle);
       
        replay();
       
        Map props = new HashMap();
        props.put("id", "bsId");
        BrowserEvent event = new BrowserEvent("onclick", new EventTarget(props));
       
        invoker.invokeFormListeners(fs, cycle, event);
       
        assertEquals(FormConstants.SUBMIT_NORMAL, fs.rewind());

        verify();
    }
View Full Code Here


    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        MockForm form = new MockForm(delegate);
        ComponentEventInvoker invoker = org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
       
        trainIsRewound(cycle, form, true);

        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        trainCycleForRewind(cycle, "refresh", "barney", null);

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

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

        form.setBody(body);
        form.setEventInvoker(invoker);
       
        trainExtractBrowserEvent(cycle);
       
        invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));

        delegate.clearErrors();

        replay();
View Full Code Here

    public void test_Rewind_Extra_Reserved_Ids(FormSupportFactory factory)
    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        ComponentEventInvoker invoker =
            org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
       
        MockForm form = new MockForm(delegate);

        trainIsRewound(cycle, form, true);

        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        trainCycleForRewind(cycle, "action_0", "action");

        final IFormComponent component = newFormComponent("action", "action_0");

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

        form.setBody(body);
        form.setEventInvoker(invoker);
       
        trainExtractBrowserEvent(cycle);
       
        invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
       
        replay();

        assertEquals(FormConstants.SUBMIT_NORMAL, fs.rewind());
View Full Code Here

    {
        Location l = newLocation();
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        ComponentEventInvoker invoker =
            org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
       
        MockForm form = new MockForm(delegate, l);

        trainIsRewound(cycle, form, true);
        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        // So, the scenario here is that component "barney" was inside
        // some kind of loop that executed twice on the render, but only once
        // on the rewind (i.e., the object was deleted in between).

        trainCycleForRewind(cycle, "barney,wilma,barney$0", null);

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

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

        form.setBody(body);
        form.setEventInvoker(invoker);
       
        trainExtractBrowserEvent(cycle);
       
        invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
       
        replay();

        try
        {
View Full Code Here

    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        MockForm form = new MockForm(delegate);
        ComponentEventInvoker invoker =
            org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
       
        trainIsRewound(cycle, form, true);

        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        trainCycleForRewind(cycle, "barney", null);

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

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

        form.setBody(body);
        form.setEventInvoker(invoker);
       
        trainExtractBrowserEvent(cycle);
       
        invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
       
        replay();

        assertEquals(FormConstants.SUBMIT_NORMAL, fs.rewind());
View Full Code Here

    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        MockForm form = new MockForm(delegate);
        ComponentEventInvoker invoker =
            org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
       
        trainIsRewound(cycle, form, true);

        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        trainCycleForRewind(cycle, "", null);

        trainExtractBrowserEvent(cycle);
       
        writer.print("DEFERRED");
       
        invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));
       
        replay();

        IRender body = new IRender()
        {
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_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

        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        MockForm form = new MockForm(delegate);
        ListenerInvoker listenerInvoker = newMock(ListenerInvoker.class);

        ComponentEventInvoker invoker = new ComponentEventInvoker();
        invoker.setInvoker(listenerInvoker);

        trainIsRewound(cycle, form, true);
        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        trainCycleForRewind(cycle, "barney,wilma,barney_0", null);

        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}, writer);

        form.setBody(body);
        form.setEventInvoker(invoker);

        trainExtractBrowserEvent(cycle);

        replay();

        Map props = new HashMap();
        props.put("id", "bsId");
        BrowserEvent event = new BrowserEvent("onclick", new EventTarget(props));

        invoker.invokeFormListeners(fs, cycle, event);

        assertEquals(FormConstants.SUBMIT_NORMAL, fs.rewind());

        verify();
    }
View Full Code Here

    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IValidationDelegate delegate = newDelegate();
        MockForm form = new MockForm(delegate);
        ComponentEventInvoker invoker = org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);

        trainIsRewound(cycle, form, true);

        trainGetPageRenderSupport(cycle, null);

        replay();

        final FormSupport fs = factory.createFormSupport(writer, cycle, form);

        verify();

        delegate.clear();

        trainCycleForRewind(cycle, "refresh", "barney", null);

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

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

        form.setBody(body);
        form.setEventInvoker(invoker);

        trainExtractBrowserEvent(cycle);

        invoker.invokeFormListeners(eq(fs), eq(cycle), isA(BrowserEvent.class));

        delegate.clearErrors();

        replay();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.internal.event.impl.ComponentEventInvoker

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.