Show/ Hide components on the selection of checkbox of a Tree

asked 2013-01-30 09:48:16 +0800

jatinsehgal86 gravatar image jatinsehgal86

The onSelect event is present for the component only and I want to show/hide my comboboxes for selected checkboxes only.

Here is my zul file for reference

<?page title="MVVM Tree POC"?>
    <borderlayout height="800px">
        <west size="25%"></west>
            <window apply="org.zkoss.bind.BindComposer"
                viewModel="@id('vm') @init('com.nagarro.viewmodel.TreeViewModel')"
                title="Dynamic Tree" border="normal">
                <tree checkmark="true" model="@bind(vm.treeModel)"
                        <treecol label="Name" align="center" />
                        <treecol label="Value" align="center" />
                        <treecol label="IP" align="center" />
                    <template name="model" var="node" status="s">
                        <treeitem checkable="@load(node.checkable)">
                            <treerow style="text-align:center;">
                                    label="@bind(node.data.firstName)" style="text-align:left;">

                                <treecell style="text-align:center;">
                                        <comboitem label="Fixed" />
                                        <comboitem label="System" />
                                        <comboitem label="Parameter" />
                                <treecell style="text-align:center;">
                                        <comboitem label="IP" />



the mvvm file

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;

import com.nagarro.model.Request;
import com.nagarro.viewmodel.helper.AdvancedTreeModel;
import com.nagarro.viewmodel.helper.TreeList;
import com.nagarro.dto.Tree;
import com.nagarro.model.TreeNode;

public class TreeViewModel {

    private Request request;
    private AdvancedTreeModel treeModel;

     * @return the treeModel
    public AdvancedTreeModel getTreeModel() {
        if(treeModel == null){
            TreeNode<Tree> treeNode = new TreeList(request).getRoot();
            treeModel = new AdvancedTreeModel(treeNode);
        return treeModel;

     * @param treeModel the TreeModel to set
    public void setTreeModel(AdvancedTreeModel treeModel) {
        this.treeModel = treeModel;
    public void init(){
        try {
            File file = new File("C:\\Users\\jatin1937\\Desktop\\XML files\\Request.xml");
            JAXBContext jaxbContext = JAXBContext.newInstance(Request.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            request = (Request) jaxbUnmarshaller.unmarshal(file);
        }catch (JAXBException e) {

     * @return the request
    public Request getRequest() {
        return request;

     * @param request the request to set
    public void setRequest(Request request) {
        this.request = request;
    public void select(){
        System.out.println("onSelect method entered");

I want to show the combo boxes only for the components which have checked checkboxes. There should not be any combobox shown for component without checkbox or unchecked checkbox. Thanks

delete flag offensive retag edit


Which checkboxes you are talking about?

sjoshi ( 2013-01-30 10:20:57 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-02-05 10:49:38 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi jatinsehgal86

You can bind checkable attribute to the combobox.

<combobox if="${node.checkable}">
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2013-01-30 09:48:16 +0800

Seen: 55 times

Last updated: Feb 05 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More