I have textbox and method which listens two events.
<textbox id="test" />
@Listen("onOK = #test; onBlur = #test")
public void action(Event event) {
// do something ...
}
When I press Enter on the Textbox, the event "onOK " is triggered. It's OK. But then when I lose focus from the Texbox the event "onBlur" is triggered too. It's bad, because in that case my method "action" is called two times. How can I cancel this second event ?
You could forward any event to another event :
I created a fiddle where you can test it.
But some explication :
In the zul :
<textbox id="test" forward="onOK=test.onBlur"/>
What says that the onOK will be forwarded to onBlur, and it will be an onBlur later on.
In java code :
@Listen("onBlur = #test")
public void action(Event event) {
Clients.showNotification(event.getName() + " " + ++counter);
}
So now we only listen for the onBlur because onOK is forwarded to the onBlur.
Will this help your case atm, not yet.
Not calling the event => not possible, if you declare it, it will be triggered.
But how can you handle your situation :
Hold the String in your composer, and check it with the new value.
If it's equal => the event is already triggered, or there are no changes.
If it's not equal => do your stuff.