blob: f7d84771355064fe6867e6170dd664658fb3e964 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<ui:composition template="/main.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://java.sun.com/jsf/facelets">
<p>The <code class="language-markup">&lt;tc:treeCommand/></code> tag can be added to a
<code class="language-markup">&lt;tc:treeNode/></code> tag.
The command can be used to execute an action or a link.</p>
<p><tc:link label="Tag Library Documentation" image="#{request.contextPath}/image/feather-leaf.png"
link="#{apiController.base}/doc/#{apiController.currentRelease}/tld/tc/treeCommand.html"/></p>
<tc:section label="Example">
<p>In this example, the nodes with children are displayed as
<code class="language-markup">&lt;tc:treeLabel/></code>. The leafs are
<code class="language-markup">&lt;tc:treeCommand/></code>.
Like the parent nodes suggest,
the entries in 'Actions' run an action with the <code>action</code> attribute.
And the entries in 'Links' are links to an external website using the <code>link</code> attribute.</p>
<tc:tree id="tree" value="#{treeCommandTypesController.sample}" var="node">
<tc:treeNode id="treeNode">
<tc:treeIndent showJunctions="false"/>
<tc:treeLabel value="#{node.name}" rendered="#{node.childCount > 0}"/>
<tc:treeCommand id="actionCommand" label="#{node.name}" rendered="#{node.childCount == 0 and empty node.url}"
action="#{treeCommandTypesController.increaseActionCount(node.action)}"/>
<tc:treeCommand label="#{node.name}" rendered="#{node.childCount == 0 and not empty node.url}"
link="#{node.url}"/>
</tc:treeNode>
</tc:tree>
<tc:out id="actionCount1" label="Action 1 Count" value="#{treeCommandTypesController.actionOneCount}"/>
<tc:out id="actionCount2" label="Action 2 Count" value="#{treeCommandTypesController.actionTwoCount}"/>
</tc:section>
</ui:composition>