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

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

Introduction

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

Prototype

public boolean isDontGoDeeper() 

Source Link

Document

Checks if the visit/traversal has been stopped from visiting children of the currently visited object

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 {/*www. j  a va  2 s .  c  o m*/
        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);
    }
}