001: /*
002: * $Id: TreeNode.java 497654 2007-01-19 00:21:57Z rgielen $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.components;
022:
023: import javax.servlet.http.HttpServletRequest;
024: import javax.servlet.http.HttpServletResponse;
025:
026: import org.apache.struts2.views.annotations.StrutsTag;
027: import org.apache.struts2.views.annotations.StrutsTagAttribute;
028:
029: import com.opensymphony.xwork2.util.ValueStack;
030:
031: /**
032: * <!-- START SNIPPET: javadoc -->
033: *
034: * Renders a tree node within a tree widget with AJAX support.<p/>
035: *
036: * Either of the following combinations should be used depending on if the tree
037: * is to be constrcted dynamically or statically. <p/>
038: *
039: * <b>Dynamically</b>
040: * <ul>
041: * <li>id - id of this tree node</li>
042: * <li>title - label to be displayed for this tree node</li>
043: * </ul>
044: *
045: * <b>Statically</b>
046: * <ul>
047: * <li>rootNode - the parent node of which this tree is derived from</li>
048: * <li>nodeIdProperty - property to obtained this current tree node's id</li>
049: * <li>nodeTitleProperty - property to obtained this current tree node's title</li>
050: * <li>childCollectionProperty - property that returnds this current tree node's children</li>
051: * </ul>
052: *
053: * <!-- END SNIPPET: javadoc -->
054: *
055: * <p/> <b>Examples</b>
056: *
057: * <pre>
058: * <!-- START SNIPPET: example -->
059: *
060: * <-- statically -->
061: * <s:tree id="..." label="...">
062: * <s:treenode id="..." label="..." />
063: * <s:treenode id="..." label="...">
064: * <s:treenode id="..." label="..." />
065: * <s:treenode id="..." label="..." />
066: * &;lt;/s:treenode>
067: * <s:treenode id="..." label="..." />
068: * </s:tree>
069: *
070: * <-- dynamically -->
071: * <s:tree
072: * id="..."
073: * rootNode="..."
074: * nodeIdProperty="..."
075: * nodeTitleProperty="..."
076: * childCollectionProperty="..." />
077: *
078: * <!-- END SNIPPET: example -->
079: * </pre>
080: *
081: */
082: @StrutsTag(name="treenode",tldTagClass="org.apache.struts2.views.jsp.ui.TreeNodeTag",description="Render a tree node within a tree widget.")
083: public class TreeNode extends ClosingUIBean {
084: private static final String TEMPLATE = "treenode-close";
085: private static final String OPEN_TEMPLATE = "treenode";
086:
087: public TreeNode(ValueStack stack, HttpServletRequest request,
088: HttpServletResponse response) {
089: super (stack, request, response);
090: }
091:
092: public String getDefaultOpenTemplate() {
093: return OPEN_TEMPLATE;
094: }
095:
096: protected String getDefaultTemplate() {
097: return TEMPLATE;
098: }
099:
100: @StrutsTagAttribute(description="Label expression used for rendering tree node label.",required=true)
101: public void setLabel(String label) {
102: super.setLabel(label);
103: }
104: }
|