Package org.apache.tapestry5.runtime

Examples of org.apache.tapestry5.runtime.ComponentEvent


        train_getCount(context, 2);
        train_get(context, Integer.class, 0, value);

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", context, handler, resources, logger);

        assertSame(event.coerceContext(0, "java.lang.Integer"), value);

        verify();
    }
View Full Code Here


        train_getCount(context, 0);

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", context, handler, null, logger);

        event.setMethodDescription("foo.Bar.baz()");

        try
        {
            event.coerceContext(1, "java.lang.Integer");
        }
        catch (IllegalArgumentException ex)
        {
            assertEquals(ex.getMessage(),
                         "Method foo.Bar.baz() has more parameters than there are context values for this component event.");
View Full Code Here

        expect(context.get(Integer.class, 0)).andThrow(new NumberFormatException("Not so easy, is it?"));

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", context, handler, resources, logger);

        event.setMethodDescription("foo.Bar.baz()");

        try
        {
            event.coerceContext(0, "java.lang.Integer");
            unreachable();
        }
        catch (IllegalArgumentException ex)
        {
            // Different JVMs will report the conversion error slightly differently,
View Full Code Here

        train_handleResult(handler, result, true);

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null, logger);

        event.setMethodDescription(methodDescription);

        assertFalse(event.isAborted());

        assertTrue(event.storeResult(result));

        assertTrue(event.isAborted());

        verify();
    }
View Full Code Here

        train_handleResult(handler, result, false);

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null, logger);

        event.setMethodDescription(methodDescription);

        assertFalse(event.storeResult(result));

        assertFalse(event.isAborted());

        verify();
    }
View Full Code Here

        train_isDebugEnabled(logger, true);
        logger.debug(eq(TapestryMarkers.EVENT_HANDLER_METHOD), isA(String.class));

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null, logger);

        event.setMethodDescription("foo.Bar.baz()");

        assertFalse(event.storeResult(null));

        assertFalse(event.isAborted());

        verify();
    }
View Full Code Here

        expect(handler.handleResult(result)).andReturn(true);

        replay();

        ComponentEvent event = new ComponentEventImpl("eventType", "someId", null, handler, null, logger);

        event.setMethodDescription("foo.Bar.baz()");
        event.storeResult(result);

        try
        {
            event.setMethodDescription("foo.Bar.biff()");
            event.storeResult(null);
            unreachable();
        }
        catch (IllegalStateException ex)
        {
            assertEquals(ex.getMessage(), ServicesMessages
View Full Code Here

            {
                // Invoke the super-class implementation first.

                invocation.proceed();

                ComponentEvent event = (ComponentEvent) invocation.getParameter(0);

                if (!event.isAborted() && event.matches(eventType, "", minContextValues))
                {
                    event.setMethodDescription(methodDescription);

                    handler.handleEvent((Component) invocation.getInstance(), event);

                    // Ensure that the caller knows that some event handler method
                    // was invoked.
View Full Code Here

        {
            try
            {
                Logger logger = component.getEventLogger();

                ComponentEvent event = new ComponentEventImpl(currentEventType, componentId, currentContext, wrapped,
                        elementResources, logger);

                logger.debug(TapestryMarkers.EVENT_DISPATCH, "Dispatch event: {}", event);

                result |= component.dispatchEvent(event);

                if (event.isAborted())
                    return result;
            }
            catch (RuntimeException ex)
            {
                // An exception in an event handler method
View Full Code Here

                // Invoke the super-class implementation first. If no super-class,
                // this will do nothing and return false.

                invocation.proceed();

                ComponentEvent event = (ComponentEvent) invocation.getParameter(0);

                if (invokeEventHandlers(event, invocation.getInstance()))
                    invocation.setReturnValue(true);
            }

            private boolean invokeEventHandlers(ComponentEvent event, Object instance)
            {
                // If the super-class aborted the event (some super-class method return non-null),
                // then it's all over, don't even check for handlers in this class.

                if (event.isAborted())
                    return false;

                boolean didInvokeSomeHandler = false;

                for (EventHandlerMethodInvoker invoker : invokersArray)
                {
                    if (event.matches(invoker.getEventType(), invoker.getComponentId(),
                            invoker.getMinContextValueCount()))
                    {
                        didInvokeSomeHandler = true;

                        invoker.invokeEventHandlerMethod(event, instance);

                        if (event.isAborted())
                            break;
                    }
                }

                return didInvokeSomeHandler;
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.runtime.ComponentEvent

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.