myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dirk Krummacker (JIRA)" <>
Subject [jira] Created: (TRINIDAD-1103) tr:tree: nodes cannot be closed if initiallyExpanded=true
Date Fri, 30 May 2008 12:25:45 GMT
tr:tree: nodes cannot be closed if initiallyExpanded=true

                 Key: TRINIDAD-1103
             Project: MyFaces Trinidad
          Issue Type: Bug
    Affects Versions:  1.0.8-core, 1.0.7-core
         Environment: Observed with Windows XP, IE6 or Firefox, Apache MyFaces Core
1.1.5 and Trinidad 1.0.7 and 1.0.8.
            Reporter: Dirk Krummacker
            Priority: Minor

The tr:tree and the tr:treetable component both have the attribute "initiallyExpanded" which
allows to open the whole tree on first rendering. While the tr:treeTable works exactly as
I would expect, the tr:tree shows some odd behavior: The tree is fully expanded, but any subsequent
click on a [-] collapse icon does not have any effect.

Test case:

1. Go to
2. Check "initiallyExpanded" and click "Update".
3. The tr:treeTable is expanded and you can close/open nodes.
4. And now go to
5. Check "initiallyExpanded" and click "Update".
6. The tr:tree is expanded, but the nodes cannot be collapsed.

----- tree.jsp -----

<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>

<%@ taglib uri="" prefix="h"%>
<%@ taglib uri="" prefix="f"%>
<%@ taglib uri="" prefix="tr"%>
<%@ taglib uri="" prefix="trh"%>

	<trh:head title="Tree Initially Expanded" />

			<tr:tree var="node" value="#{treeModelBean.treeModel}"
				<f:facet name="nodeStamp">
					<tr:outputText value="#{}" />

----- -----

package test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.model.ChildPropertyTreeModel;
import org.apache.myfaces.trinidad.model.RowKeySet;
import org.apache.myfaces.trinidad.model.RowKeySetImpl;
import org.apache.myfaces.trinidad.model.TreeModel;

public class TreeModelBean
    public TreeModel getTreeModel()
        List<Node> empty = Collections.emptyList();

        List<Node> fruits = new ArrayList<Node>();
        fruits.add(new Node("Bananas", empty));
        fruits.add(new Node("Apples", empty));
        fruits.add(new Node("Cherries", empty));

        List<Node> vegetables = new ArrayList<Node>();
        vegetables.add(new Node("Carrots", empty));
        vegetables.add(new Node("Potatoes", empty));
        vegetables.add(new Node("Salad", empty));

        List<Node> edibles = new ArrayList<Node>();
        edibles.add(new Node("Fruits", fruits));
        edibles.add(new Node("Vegetables", vegetables));

        List<Node> root = new ArrayList<Node>();
        root.add(new Node("Edibles", edibles));

        return new ChildPropertyTreeModel(root, "children");

    public static class Node
        public Node(String name, List<Node> children)
   = name;
            this.children = children;

        public String getName()
            return name;

        public List<Node> getChildren()
            return children;

        private String name;
        private List<Node> children;

----- End -----

Workaround 1: Use a tr:treeTable without columns instead of tr:tree.

Workaround 2: Don't use the attribute "initiallyExpanded" but open the nodes yourself on first
display. For this, bind the attribute "disclosedRowKeys" to the following method:

    public RowKeySet getDisclosedRowKeys()
        RequestContext requestContext = RequestContext.getCurrentInstance();
        Map<String, Object> pageFlowScope = requestContext.getPageFlowScope();
        RowKeySet disclosedRowKeys = (RowKeySet) pageFlowScope.get("disclosedRowKeys");
        if (disclosedRowKeys == null)
            disclosedRowKeys = new RowKeySetImpl();

            List<Integer> discloseRoot = Collections.singletonList(0);

            List<Integer> discloseFruits = new ArrayList<Integer>();

            List<Integer> discloseVegetables = new ArrayList<Integer>();

            pageFlowScope.put("disclosedRowKeys", disclosedRowKeys);
        return disclosedRowKeys;

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message