Example usage for org.apache.wicket.util.visit Visit isStopped

List of usage examples for org.apache.wicket.util.visit Visit isStopped

Introduction

In this page you can find the example usage for org.apache.wicket.util.visit Visit isStopped.

Prototype

public boolean isStopped() 

Source Link

Document

Checks if the visit/traversal has been stopped

Usage

From source file:org.wicketstuff.event.annotation.AnnotationEventSink.java

License:Apache License

private void onEvent(final Set<Method> onEventMethods, final Object sink, final Object payload,
        final IEvent<?> event) {
    try {//  ww w. ja v a 2 s.  c om
        for (Method method : onEventMethods) {
            if (canCallListenerInterface(sink, method)) {
                OnEvent onEvent = method.getAnnotation(OnEvent.class);
                if (isPayloadApplicableToHandler(onEvent, payload)) {
                    Object result = method.invoke(sink, payload);
                    if (result instanceof Visit<?>) {
                        Visit<?> visit = (Visit<?>) result;
                        if (visit.isDontGoDeeper()) {
                            event.dontBroadcastDeeper();
                        } else if (visit.isStopped()) {
                            event.stop();
                            break;
                        }
                    } else if (onEvent.stop()) {
                        event.stop();
                        break;
                    }
                }
            }
        }
    } catch (InvocationTargetException e) {
        if (e.getCause() instanceof ReplaceHandlerException) {
            throw ((ReplaceHandlerException) e.getCause());
        } else {
            throw new IllegalStateException("Failed to invoke @OnEvent method", e);
        }
    } catch (IllegalAccessException e) {
        throw new IllegalStateException("Failed to invoke @OnEvent method", e);
    }
}