[ 
https://issues.apache.org/jira/browse/TRINIDAD-1055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12591685#action_12591685
 ] 

Andrew Robinson commented on TRINIDAD-1055:
-------------------------------------------

Assigning this to me to have a look as I added the hide root node 
functionality. 

> Navigation from treeTable fails if rootNodeRendered="false"
> -----------------------------------------------------------
>
>                 Key: TRINIDAD-1055
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1055
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions: 1.0.7-core
>         Environment: Observed with Windows XP, IE6 or Firefox 2.0.0.14, 
> Apache MyFaces Core 1.1.5 and Trinidad 1.0.7.
>            Reporter: Dirk Krummacker
>            Assignee: Andrew Robinson
>
> I have a simple JSP page with only a commandButton and a treeTable. The 
> commandButton is wired to an action listener method that populates a list 
> with nodes and places it into page flow scope. This node list serves as the 
> treeTable's model. There is a column in the treeTable displaying a 
> commandLink, clicking on this link causes an action that is navigating to a 
> second page. The backing bean is in request scope.
> When I use the default rootNodeRendered="true", this page works as expected: 
> First the treeTable is empty. Clicking the button fills it, and now I can 
> open and close all nodes. If I click on a commandLink in the treeTable, I am 
> taken to the correct page. Everything is fine.
> However if I now set the treeTable's attribute rootNodeRendered="false" (and 
> change nothing otherwise), the commandLink navigation stops working. I still 
> can open/close nodes, but any click on a commandLink just causes the page to 
> refresh.
> What is more, if I now click on "Expand all", the commandLinks suddenly start 
> working again, just as if this "Expand All" click
> "repaired" the treetable. Also, if I specify initiallyExpanded="true" in the 
> JSP it works even if the root node is hidden.
> There is no change in behavior if the action method is specified on the bean 
> instead of the row object.
> ----- treeTable.jsp -----
> <%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/trinidad"; prefix="tr"%>
> <%@ taglib uri="http://myfaces.apache.org/trinidad/html"; prefix="trh"%>
> <f:view>
>        <trh:html>
>        <trh:head title="TreeTable" />
>        <trh:body>
>                <tr:form>
>                        <tr:commandButton text="Populate"
>                                
> actionListener="#{treeTableBean.actionListener}" />
>                        <tr:treeTable value="#{treeTableBean.treeModel}" 
> var="node"
> rootNodeRendered="false">
>                                <f:facet name="nodeStamp">
>                                        <tr:column sortable="true">
>                                                <f:facet name="header">
>                                                        <tr:outputText 
> value="Name" />
>                                                </f:facet>
>                                                <tr:commandLink 
> text="#{node.name}" action="#{node.navigate}" />
>                                        </tr:column>
>                                </f:facet>
>                        </tr:treeTable>
>                </tr:form>
>        </trh:body>
>        </trh:html>
> </f:view>
> ----- TreeTableBean.java -----
> public class TreeTableBean {
>    public TreeModel getTreeModel() {
>        RequestContext requestContext = RequestContext.getCurrentInstance();
>        Map<String, Object> pageFlowScope = requestContext.getPageFlowScope();
>        List<Node> contents = (List<Node>) pageFlowScope.get("contents");
>        if (contents == null) {
>            contents = Collections.emptyList();
>            pageFlowScope.put("contents", contents);
>        }
>        return new ChildPropertyTreeModel(contents, "children");
>    }
>    public void actionListener(ActionEvent event) {
>        List<Node> noChildren = Collections.emptyList();
>        List<Node> childrenOfRoot = new ArrayList<Node>();
>        List<Node> childrenOfA = new ArrayList<Node>();
>        childrenOfA.add(new Node("aa", noChildren));
>        childrenOfA.add(new Node("ab", noChildren));
>        childrenOfA.add(new Node("ac", noChildren));
>        childrenOfRoot.add(new Node("a", childrenOfA));
>        List<Node> childrenOfB = new ArrayList<Node>();
>        childrenOfB.add(new Node("ba", noChildren));
>        childrenOfB.add(new Node("bb", noChildren));
>        childrenOfB.add(new Node("bc", noChildren));
>        childrenOfRoot.add(new Node("b", childrenOfB));
>        Node root = new Node("root", childrenOfRoot);
>        List<Node> contents = new ArrayList<Node>();
>        contents.add(root);
>        RequestContext requestContext = RequestContext.getCurrentInstance();
>        Map<String, Object> pageFlowScope = requestContext.getPageFlowScope();
>        pageFlowScope.put("contents", contents);
>    }
>    public static class Node implements Serializable {
>        private static final long serialVersionUID = 1L;
>        private String name;
>        private List<Node> children;
>        public Node(String name, List<Node> children) {
>            this.name = name;
>            this.children = children;
>        }
>        public String getName() {
>            return name;
>        }
>        public List<Node> getChildren() {
>            return children;
>        }
>        public String navigate() {
>            return "target";
>        }
>    }
> }
> ----- faces-config.xml -----
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE faces-config PUBLIC
>    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
>    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd";>
> <faces-config>
>        <application>
>                
> <default-render-kit-id>org.apache.myfaces.trinidad.core</default-render-kit-id>
>        </application>
>        <managed-bean>
>                <managed-bean-name>treeTableBean</managed-bean-name>
>                <managed-bean-class>TreeTableBean</managed-bean-class>
>                <managed-bean-scope>request</managed-bean-scope>
>        </managed-bean>
>        <navigation-rule>
>                <display-name>treeTable</display-name>
>                <from-view-id>/treeTable.jsp</from-view-id>
>                <navigation-case>
>                        <from-outcome>target</from-outcome>
>                        <to-view-id>/target.jsp</to-view-id>
>                </navigation-case>
>        </navigation-rule>
> </faces-config>
> ----- end -----

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

Reply via email to