First time here? Check out the FAQ!
Hi,
I have a row with onClick Event :
<row id="${each.id}" onClick="@command('showDetails')" >
And a method receiver for it :
@Command
public void showDetails() {
System.out.println("clic ");
}
How can i get the id of the row clicked in showDetails?
you can pass parameters into @commands using @BindingParam, instead of just the ID it's often more useful to just pass the original each
object (no specific ID needed in the first place) ... below an example doing both, just pick the one you prefer/need:
zul:
<row id="${each.id}"
onClick="@command('showDetails', id=each.id, myobj=each)" >
command handler:
@Command
public void showDetails(@BindingParam("id") String id,
@BindingParam("myobj") MyClass myObject) {
System.out.println("click:" + id + " " + myObject);
}
If you really want/need the component id or uuid you can access the component via @ContextParam - however that's rarely needed, so I won't confuse you with details now.
Asked: 2021-02-17 02:51:21 +0800
Seen: 6 times
Last updated: Feb 17