How to use if="some condition" in ZK template tag

Masoud Sahabi picture Masoud Sahabi · Mar 11, 2013 · Viewed 12.8k times · Source

I have a <template> tag in my ZUL file, and I want to use this template when some condition accured (for example, when some LABEL's value change to some text).

Please look at below code... As you can see, "templateStatus" is my label's name, but it did not work.

How can I fix this issue?

    <template name="allTaskTemplate" var="allTask" if="templateStatus.value == 'allTask'">
        <row>
            <label value="" />
            <label value="@load(allTask.documentDTO.docTypeDTO.title)"/>
            <label value="@load(allTask.documentDTO.docNumber)"/>
            <label value="@load(allTask.documentDTO.docDateTime)"/>
            <label value="@load(allTask.assignerID)"/>
            <label value="@load(allTask.assigneeID)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.assignDateTime)"/>
            <label value="@load(allTask.documentDTO.docTypeStateDTO.stateActionDTO.actionDTO.title)"/>
            <label value="@load(allTask.catalogDTO.catalogTypeDTO.title)"/>
        </row>
    </template>
</grid>

Answer

nsharma picture nsharma · Jun 18, 2013

Using an if statement:

<zk if="${vm.type=='foo'}">
    <!-- Child components -->
</zk>

<zk if="${vm.type=='check'}">
    <!-- Child components -->
</zk>

<zk if="${vm.type=='something'}">
    <!-- Child components -->
</zk>

<zk if="${vm.type=='value'}">
    <!-- Child components -->
</zk>