Daniele Milani
Daniele Milani

Reputation: 573

ZK @listen annotation

I have the following problem: I have a zk page which contains four groupbox, whose id are "id_gb1", "id_gb2", "id_gb3" and "id_gb4". I created a Java controller (extending GenericForwardComposer) in which I have the following lines:

[...]
@Listen("onClick = #id_gb1; onClick = #id_gb2; onClick = #id_gb3; onClick = #id_gb4")
private void onClick() {
  //do some stuff
}
[...]

and I set the value of the attribute apply of the window element in the zk file with the class name. The problem is that when I click on the label of the groupbox nothing appens: furthermore, if I write in the same Java controller

[...]
public void onClick$id_gb1() {
  //do some stuff
}
[...]

it works!

Does anyone know what I'm doing wrong? Thanks, Daniele

Upvotes: 0

Views: 2381

Answers (2)

Masoud Sahabi
Masoud Sahabi

Reputation: 223

I used the sclass property for the components, and then in the controller I used only one @Listen for all similar components, which in turn had same the method to call.

zul file :

<toolbarbutton sclass="inLineBtns" .../>
<toolbarbutton sclass="inLineBtns" .../>
<toolbarbutton sclass="inLineBtns" .../>

Controller file which extends the SelectorComposer class:

@Listen("onClick = .inLineBtns")
public void doSomthing(){
...
}

Notice the dot, that indicates that it is a class name, not the component's ID.

Upvotes: 1

Sean Connolly
Sean Connolly

Reputation: 5801

There were some big changes moving from ZK5 to ZK6.

ZK5:
Use GenericForwardComposer and onClick$myButton syntax.

ZK6:
Use SelectorComposer and @Listen annotations.

On the topic, ZK6.5 introduces the MVVM layout which you might want to look into if you're learning ZK.

Upvotes: 3

Related Questions