1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 * <-- statically -->
55 * <s:tree id="..." label="...">
56 * <s:treenode id="..." label="..." />
57 * <s:treenode id="..." label="...">
58 * <s:treenode id="..." label="..." />
59 * <s:treenode id="..." label="..." />
60 * &;lt;/s:treenode>
61 * <s:treenode id="..." label="..." />
62 * </s:tree>
63 *
64 * <-- dynamically -->
65 * <s:tree
66 * id="..."
67 * rootNode="..."
68 * nodeIdProperty="..."
69 * nodeTitleProperty="..."
70 * childCollectionProperty="..." />
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 }