View Javadoc

1   /*
2    * $Id: TreeNode.java 451544 2006-09-30 05:38:02Z mrdon $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.components;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  
23  import com.opensymphony.xwork2.util.ValueStack;
24  
25  /***
26   * <!-- START SNIPPET: javadoc -->
27   *
28   * Renders a tree node within a tree widget with AJAX support.<p/>
29   *
30   * Either of the following combinations should be used depending on if the tree 
31   * is to be constrcted dynamically or statically. <p/>
32   * 
33   * <b>Dynamically</b>
34   * <ul>
35   * 		<li>id - id of this tree node</li>
36   * 		<li>title - label to be displayed for this tree node</li>
37   * </ul>
38   * 
39   * <b>Statically</b>
40   * <ul>
41   * 		<li>rootNode - the parent node of which this tree is derived from</li>
42   * 		<li>nodeIdProperty - property to obtained this current tree node's id</li>
43   * 		<li>nodeTitleProperty - property to obtained this current tree node's title</li>
44   * 		<li>childCollectionProperty - property that returnds this current tree node's children</li>
45   * </ul>
46   *
47   * <!-- END SNIPPET: javadoc -->
48   *
49   * <p/> <b>Examples</b>
50   *
51   * <pre>
52   * <!-- START SNIPPET: example -->
53   * 
54   * &lt-- statically --&gt;
55   * &lt;s:tree id="..." label="..."&gt;
56   *    &lt;s:treenode id="..." label="..." /&gt;
57   *    &lt;s:treenode id="..." label="..."&gt;
58   *        &lt;s:treenode id="..." label="..." /&gt;
59   *        &lt;s:treenode id="..." label="..." /&gt;
60   *    &;lt;/s:treenode&gt;
61   *    &lt;s:treenode id="..." label="..." /&gt;
62   * &lt;/s:tree&gt;
63   * 
64   * &lt;-- dynamically --&gt;
65   * &lt;s:tree
66   *          id="..."
67   *          rootNode="..."
68   *          nodeIdProperty="..."
69   *          nodeTitleProperty="..."
70   *          childCollectionProperty="..." /&gt;
71   * 
72   * <!-- END SNIPPET: example -->
73   * </pre>
74   *
75   *
76   * @s.tag name="treenode" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.TreeNodeTag"
77   * description="Render a tree node within a tree widget."
78   */
79  public class TreeNode extends ClosingUIBean {
80      private static final String TEMPLATE = "treenode-close";
81      private static final String OPEN_TEMPLATE = "treenode";
82  
83      public TreeNode(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
84          super(stack, request, response);
85      }
86  
87      public String getDefaultOpenTemplate() {
88          return OPEN_TEMPLATE;
89      }
90  
91      protected String getDefaultTemplate() {
92          return TEMPLATE;
93      }
94  
95      /***
96       * Label expression used for rendering tree node label.
97       * @s.tagattribute required="true"
98       */
99      public void setLabel(String label) {
100         super.setLabel(label);
101     }
102 }