Search code examples
javazk

zk listbox visible if model size greater than zero


I want to hide my listbox if model is empty.

 <listbox  visible="@load(vm.list.size gt 0)" model="@load(vm.list)">...</listbox>

I got an error

For input string: "size" at [file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp4/wtpwebapps/kApp/request/Approval.zul, line:162]

I think this error, because ZK ListModelList doesn't have property getSize, it has only function size, that return the size of its.


Solution

  • You can use the ()-brackets to call the function directly:

    <listbox  visible="@load(vm.list.size() gt 0)" model="@load(vm.list)">...</listbox>
    

    Here is a working fiddle example.