-
Notifications
You must be signed in to change notification settings - Fork 169
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
Cannot intercept to CustomEvent on the server-side #4628
Comments
I have similar issue, but I found strange behaviour Preconditions:custom Vaadin component based on html + java code linked via Behaviour:
|
@greenhost87 Wasn't the conclusion in your case that the problem was that events were fired already before Flow had any chance to attach its event listeners? |
@Legioth We discuss that problem in Gitter. For the record I copy more detailed description of my problem and my Solution. DescriptionI want to use i18n localization in my Vaadin html template. For this I use approach from GH-3906 direct link to Gist. ExampleFirst casePut component tag Html template code is: <dom-module id="main">
<template>
<my-component id="my-test-component">
</my-component>
</template
</dom-module> Java class of main component: class Main extends PolymerTemplate<TemplateModel> {
@Id("my-test-component")
private MyComponent component;
} Second casePut component tag Html template code is: <dom-module id="main">
<template>
<div id="holder">
</div>
</template>
</dom-module> Java code is: class Main extends PolymerTemplate<TemplateModel> {
@Id("holder")
private Div div;
public Main() {
div.add(new MyComponent());
}
} ProblemIf I use first approach no events go to server. Expected behaviourIn both approach events not lost. I think this can be designed like some My solutionAdd to component mixin method _setInitializationCompleted() {
this.initializationCompleted = true
} And modify In java code, inside component constructor add: this.getElement().callFunction("_setInitializationCompleted"); In result any localization events attempt to send self only after binding between Polymer and Vaadin is completed |
Description of the bug
I want to rise a custom event from the client code of a component, and I want to trigger an eventListener on the server-side.
@eventhandler only works with polymer events like on-click, so we need to register our own listener.
Minimal reproducible example
my-comp.html:
MyComp.java
...
...
When this.dispatchEvent(new CustomEvent('serverEvent'), {}); is executed, an event triggers the server side listener.
alert("Original click event: " + e.target); opens the alert message, but nothing happens on the server code.
The text was updated successfully, but these errors were encountered: