Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2456

MVVM command parameter cannot be evaluated inside a native component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 7.0.4
    • 7.0.3
    • Databind 2
    • 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).

            hanhsu hanhsu
            jumperchen jumperchen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: