-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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.getChildren().clear();
div.appendChild(Executions.createComponents("small.zul", div, params));
Selectors.wireEventListeners(div, this);
}
@Listen("onClick = button")
public void aaa() {
Messagebox.show("onClick on button received");
}
Asked: 2014-08-18 16:16:52 +0800
Seen: 14 times
Last updated: Aug 19 '14