-
Bug
-
Resolution: Fixed
-
Normal
-
7.0.3
-
None
-
None
For example,
test.zul
<window id="mainWindow" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.MyVM')" height="100%" width="100%"> <div children="@load(vm.items)" xmlns:n="native" xmlns:h="xhtml"> <template name="children"> <div>${each}</div> <n:div><h:button onClick="@command('selected',item=each)">test</h:button></n:div> </template> </div> </window>
test.MyVM.java
package test; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.zk.ui.util.Clients; public class MyVM { private String[] items = {"Demo", "Edit", "Add"}; public void setItems(String[] items) { this.items = items; } public String[] getItems() { return this.items; } @Command public void selected(@BindingParam("item") String selected) { Clients.log("Selected: " + selected); } }
If you change to use <div> or <h:div> instead of <n:div>, and then it should work well with @command('selected',item=each).