1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts2.components;
22
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25
26 import org.apache.struts2.views.annotations.StrutsTag;
27 import org.apache.struts2.views.annotations.StrutsTagAttribute;
28
29 import com.opensymphony.xwork2.util.ValueStack;
30
31 /***
32 * <!-- START SNIPPET: javadoc -->
33 *
34 * Renders a tree node within a tree widget with AJAX support.<p/>
35 *
36 * Either of the following combinations should be used depending on if the tree
37 * is to be constrcted dynamically or statically. <p/>
38 *
39 * <b>Dynamically</b>
40 * <ul>
41 * <li>id - id of this tree node</li>
42 * <li>title - label to be displayed for this tree node</li>
43 * </ul>
44 *
45 * <b>Statically</b>
46 * <ul>
47 * <li>rootNode - the parent node of which this tree is derived from</li>
48 * <li>nodeIdProperty - property to obtained this current tree node's id</li>
49 * <li>nodeTitleProperty - property to obtained this current tree node's title</li>
50 * <li>childCollectionProperty - property that returnds this current tree node's children</li>
51 * </ul>
52 *
53 * <!-- END SNIPPET: javadoc -->
54 *
55 * <p/> <b>Examples</b>
56 *
57 * <pre>
58 * <!-- START SNIPPET: example -->
59 *
60 * <-- statically -->
61 * <s:tree id="..." label="...">
62 * <s:treenode id="..." label="..." />
63 * <s:treenode id="..." label="...">
64 * <s:treenode id="..." label="..." />
65 * <s:treenode id="..." label="..." />
66 * &;lt;/s:treenode>
67 * <s:treenode id="..." label="..." />
68 * </s:tree>
69 *
70 * <-- dynamically -->
71 * <s:tree
72 * id="..."
73 * rootNode="..."
74 * nodeIdProperty="..."
75 * nodeTitleProperty="..."
76 * childCollectionProperty="..." />
77 *
78 * <!-- END SNIPPET: example -->
79 * </pre>
80 *
81 */
82 @StrutsTag(name="treenode", tldTagClass="org.apache.struts2.views.jsp.ui.TreeNodeTag", description="Render a tree node within a tree widget.")
83 public class TreeNode extends ClosingUIBean {
84 private static final String TEMPLATE = "treenode-close";
85 private static final String OPEN_TEMPLATE = "treenode";
86
87 public TreeNode(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
88 super(stack, request, response);
89 }
90
91 public String getDefaultOpenTemplate() {
92 return OPEN_TEMPLATE;
93 }
94
95 protected String getDefaultTemplate() {
96 return TEMPLATE;
97 }
98
99 @StrutsTagAttribute(description="Label expression used for rendering tree node label.", required=true)
100 public void setLabel(String label) {
101 super.setLabel(label);
102 }
103 }