KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > tree > TreeContent


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.tree;
19
20 import org.apache.beehive.netui.tags.AbstractSimpleTag;
21 import org.apache.beehive.netui.util.logging.Logger;
22
23 import javax.servlet.jsp.JspException JavaDoc;
24 import java.io.IOException JavaDoc;
25
26 /**
27  * @jsptagref.tagdescription Set the additional content that will be displayed on the right of the label of a tree.
28  * @example The following example shows a <netui:tree> tag with both a
29  * child <netui:treeLabel> and <netui:treeContent> tag that form the
30  * label and the additional text displayed to the righ of the label for the
31  * root folder of the tree.
32  *
33  * <pre> &lt;netui:tree dataSource="pageFlow.myTree" selectionAction="postback" tagId="myTree">
34  * &lt;netui:treeItem expanded="true" >
35  * &lt;netui:treeLabel>Root Folder&lt;/netui:treeLabel>
36  * &lt;netui:treeContent>Content to right of label: Root Folder&lt;/netui:treeContent>
37  * &lt;/netui:treeItem>
38  * &lt;/netui:tree></pre>
39  * @netui:tag name="treeContent" body-content="scriptless"
40  * description="Set the additional content that will be displayed on the right of the label of a tree."
41  * @see org.apache.beehive.netui.tags.tree.Tree
42  * @see org.apache.beehive.netui.tags.tree.TreeElement
43  */

44 public class TreeContent extends AbstractSimpleTag
45 {
46     private static final Logger logger = Logger.getInstance(TreeContent.class);
47     private String JavaDoc _text;
48
49     /**
50      * Return the name of the Tag.
51      */

52     public String JavaDoc getTagName()
53     {
54         return "TreeLabel";
55     }
56
57     /**
58      * Add this node to the parent.
59      * @throws JspException if a JSP exception has occurred
60      */

61     public void doTag()
62             throws JspException JavaDoc, IOException JavaDoc
63     {
64         String JavaDoc value = getBufferBody(true);
65         if (value != null)
66             _text = value;
67
68         Object JavaDoc o = getParent();
69         assert (o != null);
70         if (!(o instanceof TreeItem)) {
71             logger.error("Invalid Parent (expected a TreeItem):" + o.getClass().getName());
72             return;
73         }
74
75         // assign the value to the parent's label value
76
TreeItem ti = (TreeItem) o;
77         ti.setItemContent(_text);
78     }
79 }
80
Popular Tags