No events for button created with Executions.createComponents

asked 2014-08-18 16:16:52 +0800

adamian gravatar image adamian
15 4

updated 2014-08-18 16:18:21 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9

Hello all,

Example here: zkfiddle.org/sample/recb3b/5-test#source-2

Expected behavior: 1. Click on "call on Executions.createComponents()" 2. Message box appears, click on "OK". 3. Click on "click me 1" 4. Expected new message box.

I have an event listener (@Listen("onClick = button")), but the function is not called for a button created through Executions.createComponents("sample.zul", parentDiv, params);.

Any ideas what I'm doing wrong or a workaround?

Thanks, Andrei

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-19 03:26:47 +0800

RaymondChao gravatar image RaymondChao
386 1 4

updated 2014-08-19 03:36:01 +0800

Hello Andrei,

The composer wires event listener when doAfterCompose. So the button created after clicked did not wire the event listener.

You can add event listeners to button based on the composer by invoking Selectors.wireEventListeners(component, controller) like below:

@Listen("onClick = #btn")
public void onClick(Event e) throws InterruptedException{
    Map params = new HashMap();
    params.put("n", i++);
    div.appendChild(Executions.createComponents("small.zul", div, params));
    Selectors.wireEventListeners(div, this); 

@Listen("onClick = button")
public void aaa() {
    Messagebox.show("onClick on button received");
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




Asked: 2014-08-18 16:16:52 +0800

Seen: 14 times

Last updated: Aug 19 '14

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