KickJava   Java API By Example, From Geeks To Geeks.

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


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 text displayed for the selection link the given tree node (the TreeItem tag).
28  *
29  * <p>Note that a <code>&lt;netui:treeLabel></code> tag is required for all non-leaf nodes in the tree.</p>
30  * @netui:tag name="treeLabel" body-content="scriptless" description="Set the label for the parent TreeItem."
31  * @see org.apache.beehive.netui.tags.tree.Tree
32  * @see org.apache.beehive.netui.tags.tree.TreeElement
33  */

34 public class TreeLabel extends AbstractSimpleTag
35 {
36     private static final Logger logger = Logger.getInstance(TreeLabel.class);
37
38     private String JavaDoc _text;
39
40     /**
41      * Return the name of the Tag.
42      */

43     public String JavaDoc getTagName()
44     {
45         return "TreeLabel";
46     }
47
48     /**
49      * Add this node to the parent.
50      * @throws JspException if a JSP exception has occurred
51      */

52     public void doTag()
53             throws JspException JavaDoc, IOException JavaDoc
54     {
55         String JavaDoc value = getBufferBody(true);
56         if (value.length() > 0)
57             _text = value;
58
59         Object JavaDoc o = getParent();
60         assert (o != null);
61         if (!(o instanceof TreeItem)) {
62             logger.error("Invalid Parent (expected a TreeItem):" + o.getClass().getName());
63             return;
64         }
65
66         // assign the value to the parent's label value
67
TreeItem ti = (TreeItem) o;
68         ti.setItemLabel(_text);
69     }
70 }
71
Popular Tags