Package org.apache.tapestry.internal.event

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


     * {@inheritDoc}
     */
    public void addElementEventListener(String elementId, String[] events,
            String methodName, String formId, boolean validateForm, boolean async, boolean focus)
    {
        ComponentEventProperty property = getElementEvents(elementId);
        if (property == null) {
            property = new ComponentEventProperty(elementId);
            _elementEvents.put(elementId, property);
        }

        property.addListener(events, methodName, formId, validateForm, async, focus, true);
    }
View Full Code Here


    public void connectAutoSubmitEvents(IComponent component, IForm form)
    {
        Defense.notNull(form, "form");
       
        ComponentEventProperty property = getComponentEvents(component.getExtendedId());
       
        if (property == null)
            return;

        property.connectAutoSubmitEvents(form.getExtendedId());
    }
View Full Code Here

        property.connectAutoSubmitEvents(form.getExtendedId());
    }

    public void rewireComponentId(String componentId, String idPath)
    {
        ComponentEventProperty prop = getComponentEvents(componentId);
        if (prop == null)
            return;

        if (_componentEvents.containsKey(idPath))
            return;

        try {

            ComponentEventProperty clone = (ComponentEventProperty) prop.clone();

            clone.rewireComponentId(idPath);

            _componentEvents.put(idPath, clone);

        } catch (CloneNotSupportedException e) {
View Full Code Here

       
        Iterator it = _componentEvents.keySet().iterator();
        while (it.hasNext()) {
           
            String compId = (String)it.next();
            ComponentEventProperty prop = (ComponentEventProperty)_componentEvents.get(compId);

            ret.addAll(prop.getFormEventListeners(formId, event, null));
        }
       
        it = _elementEvents.keySet().iterator();
        while (it.hasNext()) {
           
            String compId = (String)it.next();
            ComponentEventProperty prop = (ComponentEventProperty)_elementEvents.get(compId);

            ret.addAll(prop.getFormEventListeners(formId, event, null));
        }
       
        return (EventBoundListener[])ret.toArray(new EventBoundListener[ret.size()]);
    }
View Full Code Here

        spec.addEventListener("comp1", new String[] {"onClick"}, "testFoo", null, false, false, false, false);
       
        assert spec.getComponentEvents("comp1") != null;
        assert spec.getComponentEvents("comp1").getEvents().size() == 1;
       
        ComponentEventProperty prop = spec.getComponentEvents("comp1");
        assertNotNull(prop);
        assertEquals(prop.getEventListeners("onClick").size(), 1);
       
        prop = spec.getComponentEvents("comp2");
        assert prop == null;
    }
View Full Code Here

        spec.addEventListener("comp1", new String[] {"onClick"}, "testFoo", "form", false, true, false, false);
        spec.addEventListener("comp1", new String[] {"onClick"}, "testBar", "form", false, true, false, false);
       
        assert spec.getComponentEvents("comp1") != null;
       
        ComponentEventProperty p = spec.getComponentEvents("comp1");
       
        // should be only form events bound
        assertEquals(p.getEvents().size(), 0);
        assertEquals(p.getEventListeners("onClick").size(), 0);
       
        assertEquals(p.getComponentId(), "comp1");
        assertEquals(p.getFormEventListeners("onClick").size(), 2);
        assertEquals(p.getFormEvents().size(), 1);
    }
View Full Code Here

        String[] compIds = (String[]) keySet.toArray(new String[keySet.size()]);
       
        for (int i=0; i < compIds.length; i++)
        {
            String compId = compIds[i];
            ComponentEventProperty property = (ComponentEventProperty) events.get(compId);

            // find the targeted component

            IComponent comp = findComponent(compId, component.getPage());

            if (comp == null)
                continue;

            if (Component.class.isInstance(comp))
                ((Component)comp).setHasEvents(true);
           
            // wire up with idPath

            String idPath = comp.getExtendedId();
           
            component.getSpecification().rewireComponentId(compId, idPath);
           
            _invoker.addEventListener(idPath, component.getSpecification());
            wireFormEvents(comp, component.getSpecification());
        }
       
        // find form element targets for re-mapping with proper idpath && IEventInvoker connection

        events = component.getSpecification().getElementEvents();
        Iterator it = events.keySet().iterator();

        // for efficiency later in ComponentEventConnectionWorker

        if (events.size() > 0 && Component.class.isInstance(component)) {
            ((Component)component).setHasEvents(true);
        }

        while (it.hasNext())
        {
            String elementId = (String) it.next();
            ComponentEventProperty property = (ComponentEventProperty) events.get(elementId);

            Iterator bindingIt  = property.getFormEvents().iterator();
            while (bindingIt.hasNext())
            {
                String key = (String) bindingIt.next();
                List listeners = property.getFormEventListeners(key);

                for (int i=0; i < listeners.size(); i++) {
                   
                    EventBoundListener listener = (EventBoundListener) listeners.get(i);
                    wireElementFormEvents(listener, component, component.getSpecification());
View Full Code Here

        for (int i = 0; i < listeners.size(); i++)
        {
            IComponentSpecification listener = (IComponentSpecification)listeners.get(i);

            IComponent target;
            ComponentEventProperty props;

            if (listener.isPageSpecification())
            {
                target = component.getPage();
                props = listener.getComponentEvents(idPath);
            } else
            {
                target = findComponent(component.getPage().getComponents().values(), listener);
                props = target.getSpecification().getComponentEvents(idPath);
            }
           
            if (props == null)
                continue;

            List clisteners = props.getEventListeners(event.getName());
            for (int e=0; e < clisteners.size(); e++)
            {
                EventBoundListener eventListener = (EventBoundListener)clisteners.get(e);

                _invoker.invokeListener(target.getListeners().getListener(eventListener.getMethodName()), target, cycle);
View Full Code Here

    {
        String targetId = (String)event.getTarget().get("id");
        if (targetId == null)
            return;

        ComponentEventProperty prop = component.getSpecification().getElementEvents(targetId);
        if (prop == null)
            return;

        List listeners = prop.getEventListeners(event.getName());

        for (int i=0; i < listeners.size(); i++)
        {
            EventBoundListener listener = (EventBoundListener)listeners.get(i);
View Full Code Here

    {
        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);
View Full Code Here

TOP

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

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.