0

ZK Problem with multiple events

asked 2016-05-25 06:07:16 +0800

AndriySV gravatar image AndriySV
13 2

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 ?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-05-25 06:53:28 +0800

IngoB gravatar image IngoB flag of Germany
256 6

You could add a boolean flag.

boolean finished= false;

private void method1() {
    if (!finished) {
        //...
        finished= true;
    }
}

private void method2() {
    if (!finished) {
        //...
        finished= true;
    }
}

Another option could be to stop the event propagation => #stopPropagation()

link publish delete flag offensive edit
0

answered 2016-05-27 03:49:19 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

The issue is the 2 events, onOK and onBlur, have different meaning but invoke the same listener. This is not a usual case. Maybe you should separate action() into 2 different listeners.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-05-25 06:07:16 +0800

Seen: 21 times

Last updated: May 27 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More