Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional annotation for OnEvent to override AnnotationEventSink.canCallListenerInterface to easier work with hidden components? #493

Open
ams-tschoening opened this issue May 11, 2016 · 0 comments

Comments

@ams-tschoening
Copy link
Contributor

I have an at first invisble panel to render some data, which gets its data by an event using AnnotationEventDispatcher and the availibility of the data influences isVisible of the panel. AnnotationEventSink.canCallListenerInterface is used to decide if an event should be dispatched to an EventSink or not and by default my panel is ignored because it starts invisble. As I understand the docs of Component.canCallListenerInterface, this is a use case in which I should override canCallListenerInterface and decide that the event should be dispatched to the invisible panel without running into too much trouble. So I did that and dispatching the event and rendering the data works.

@Override
public boolean canCallListenerInterface(Method method)
{
    if (method.isAnnotationPresent(OnEvent.class))
    {
        return true;
    }

    return super.canCallListenerInterface(method);
}

This implemenation is much like the criteria AnnotationEventDispatcher uses on its own to find the annotated event callbacks.

So what do you think about enhancing the OnEvent annotation itself with a boolean to optionally be able override the check of AnnotationEventSink.canCallListenerInterface directly? The additionaly booleas would simply be taken into account like stop already. This way one wouldn't need to override canCallListenerInterface per component in uses cases like mine, but the annotated event handler itself could already decide to dispatch an event in all cases.

Additionally, the boolean could be used as well to simply document the fact that canCallListenerInterface is called before an event is dispatched to an EventSink and may easier be recognized. I was not aware of that behavior, wondered why my handler is never called and needed to find out using the debugger.

Thanks.

@ams-tschoening ams-tschoening changed the title Additional annotation for AnnotationEventSink.canCallListenerInterface to easier work with hidden components? Additional annotation for OnEvent to override AnnotationEventSink.canCallListenerInterface to easier work with hidden components? May 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant