1

Zk EventListener Priority NotWorking

asked 2015-07-06 17:50:53 +0800

javiut gravatar image javiut flag of Venezuela, Bolivarian Republic of
90 1 5

I have a code a like this.

public final class CustomCheckBox extends Checkbox
{
private static final long serialVersionUID = 721911981209434340L;
private final Logger log = Logger.getLogger(getClass());
public CustomCheckBox() 
{
    super();
    log.info("BEFORE1");
    addEventListener(-10000,Events.ON_CREATE,new EventListener<Event>(){
        public void onEvent(final Event event)throws Exception
        {
            log.info("onCreateJavaCalled");
        }
    });
    log.info("AFTER1");
    return;
}

And in a ZUL something like this

<listcell sclass="textColumn"><customcheckbox onCreate='System.out.println("ZUL onCreateCalled..")'/></listcell>

The ZK documentation says

Notice:
If the priority equals or is greater than 1000, the event listener will be invoked   before the event handlers registered in a ZUML page (i.e., the onXxx attribute declared in ZUML). On the other hand, if the priority is lower than 1000, it is invoked after the ZUML's event handler.
The priority registered by addEventListener(String, EventListener) is 0.

Applications shall not use the priority higher than 10,000 and lower than -10,000 since they are reserved for component development.

But i see in console like this.

BEFORE1
AFTER1
onCreateJavaCalled
ZUL onCreateCalled..

Clearly Java onCreate method which should be last is being called first i think this is because the ZUL onCreate is not being set yet any approach to be my onCreate ZUL method called first.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-07-07 08:10:56 +0800

chillworld gravatar image chillworld flag of Belgium
5357 4 9
https://github.com/chillw...

Hey Javiut,

I created a fiddle with static integer to show you the correct order.

The order there is :

  • BEFORE 1
  • AFTER 2
  • (pos) onCreateJavaCalled 3
  • ZUL onCreateCalled 4
  • (neg) onCreateJavaCalled 5

Can you check with this setup?

Greetz chill.

link publish delete flag offensive edit

Comments

Yep but i want my ZUL onCreate always runs first that onCreate Java method how can i do it..

javiut ( 2015-07-07 14:05:56 +0800 )edit

normally like you described, and the fiddle does also what you described. That's why I asked to check with static ints (because sometimes output logger isn't correct in order)

chillworld ( 2015-07-07 14:13:33 +0800 )edit

btw, try hard coded onCreate : http://zkfiddle.org/sample/2cni966/2-eventlistener-priority

chillworld ( 2015-07-07 14:16:18 +0800 )edit

Thanks works using a hardCoded onCreate

javiut ( 2015-07-07 14:41:40 +0800 )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: 2015-07-06 17:50:53 +0800

Seen: 17 times

Last updated: Jul 07 '15

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