myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: [Trinidad] treeTable: Navigation fails when rootNodeRendered="false"
Date Tue, 22 Apr 2008 16:23:37 GMT
You can probably file a bug.

Out of curiosity, does it work if your action method is on a bean and not a
node?

-Andrew

On Tue, Apr 22, 2008 at 9:58 AM, Dirk Krummacker <dirk.krummacker@gmail.com>
wrote:

> 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.
>
> 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.
>
> The bean is in request scope. I am using Apache MyFaces Core 1.1.5 and
> Trinidad 1.0.7.
>
> Is there something I have to do to make this test case work even when
> I want rootNodeRendered="false"? Or is this a bug? Or is there a
> totally different approach that allows me to hide the root node and
> have navigation from the columns at the same time?
>
> Thanks in advance,
>
> Dirk
>
> ----- 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 -----
>

Mime
View raw message