Search code examples
javazk

ZK Component Set Component Not Value


It seems very simple and maybe silly. But I couldn't find a way to set reverse of the combobox disabled value into the a(id=add) visibility.

<combobox id="cb" model="@{cont.values}" autodrop="true" disabled="true" readonly="false" >
    <comboitem self="@{each=val}"  label="@{val.name}" />
</combobox>
<a id="add" iconSclass="icon-plus-sign" visible="${cb.disabled}"/>
  • if combobox is disabled a is NOT visible
  • if combobox is enabled a is visible

How to make this? The above form in my solution makes the exact opposite what I want.


Solution

  • Use EL expression NOT operator

    visible="${not cb.disabled}"
    

    Refer here for more details about EL expression operators within ZUML

    Update: Here is a working sample

    <zk>
        <combobox id="cb" disabled="true" readonly="false" >
           <comboitem label="Test 1" />
           <comboitem label="Test 2" />
           <comboitem label="Test 3" />
        </combobox>
        <a id="add" visible="${not cb.disabled}">Add</a>
    </zk>