KickJava   Java API By Example, From Geeks To Geeks.

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


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
25 /**
26  * @jsptagref.tagdescription Set an attribute on the tree.
27  * @example The following example shows a <netui:tree> tag with both a
28  * child <netui:treeLabel> and <netui:treeHtmlAttribute> tag that form the
29  * label for the root folder of the tree. The <netui:treeHtmlAttribute>
30  * outputs the attribute <code>name="A1"</code> on the anchor element used for
31  * the selection link of the tree item.
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:treeHtmlAttribute attribute="name" value="A1" onSelectionLink="true"/>
37  * &lt;/netui:treeItem>
38  * &lt;/netui:tree></pre>
39  * @netui:tag name="treeHtmlAttribute" body-content="empty" description="Set an attribute on the tree."
40  * @see org.apache.beehive.netui.tags.tree.Tree
41  * @see org.apache.beehive.netui.tags.tree.TreeElement
42  */

43 public class TreeHtmlAttribute extends AbstractSimpleTag
44 {
45     private static final Logger logger = Logger.getInstance(TreeHtmlAttribute.class);
46
47     TreeHtmlAttributeInfo _info = new TreeHtmlAttributeInfo();
48
49     /**
50      * Return the name of the Tag.
51      */

52     public String JavaDoc getTagName()
53     {
54         return "TreeHtmlAttribute";
55     }
56
57     /**
58      * Sets the name of the attribute. This must be in the proper HTML Attribute form. For example,
59      * "onmouseclick" or "href".
60      * @param attr the name of the HTML attribute.
61      * @jsptagref.attributedescription Sets the name of the attribute. This must be in the proper HTML Attribute form. For example,
62      * "onmouseclick" or "href".
63      * @jsptagref.databindable false
64      * @jsptagref.attributesyntaxvalue <i>string</i>
65      * @netui:attribute required="true"
66      * description="Sets the name of the attribute."
67      */

68     public void setAttribute(String JavaDoc attr)
69     {
70         _info.setAttribute(attr);
71     }
72
73     /**
74      * Sets HTML attribute value.
75      * @param value The value of the HTML Attribute.
76      * @jsptagref.attributedescription Sets the HTML attribute value.
77      * @jsptagref.databindable true
78      * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
79      * @netui:attribute required="true"
80      * description="Sets HTML attribute value."
81      */

82     public void setValue(String JavaDoc value)
83     {
84         _info.setValue(value);
85     }
86
87     /**
88      * @param onIcon
89      * @jsptagref.attributedescription Set the attribute value on the icon
90      * @jsptagref.databindable true
91      * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
92      * @netui:attribute required="false"
93      * description="Set the attribute value on the icon."
94      */

95     public void setOnIcon(boolean onIcon)
96     {
97         _info.setOnIcon(onIcon);
98     }
99
100     /**
101      * @param onSelectionLink
102      * @jsptagref.attributedescription Set the attribute value on the link around the icon.
103      * @jsptagref.databindable true
104      * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
105      * @netui:attribute required="false"
106      * description="Set the attribute value on the link around the icon."
107      */

108     public void setOnSelectionLink(boolean onSelectionLink)
109     {
110         _info.setOnSelectionLink(onSelectionLink);
111     }
112
113     /**
114      * @param onDiv
115      * @jsptagref.attributedescription Set the attribute value on the item &lt;div>.
116      * @jsptagref.databindable true
117      * @jsptagref.attributesyntaxvalue <i>string_or_expression</i>
118      * @netui:attribute required="false"
119      * description="Set the attribute value on the item div."
120      */

121     public void setOnDiv(boolean onDiv)
122     {
123         _info.setOnDiv(onDiv);
124     }
125
126     /**
127      * @param applyToDescendents
128      * @jsptagref.attributedescription Apply the attribute to descendents of this node.
129      * @jsptagref.databindable true
130      * @jsptagref.attributesyntaxvalue <i>boolean</i>
131      * @netui:attribute required="false"
132      * description="Apply the attribute value to descendents of this node."
133      */

134     public void setApplyToDescendents(boolean applyToDescendents)
135     {
136         _info.setApplyToDescendents(applyToDescendents);
137     }
138
139     public void doTag()
140             throws JspException JavaDoc
141     {
142         Object JavaDoc o = getParent();
143         assert (o != null);
144
145         if (o instanceof TreeItem) {
146             TreeItem ti = (TreeItem) o;
147             ti.setItemAttribute(_info);
148         }
149         else {
150             logger.error("Found an unexpected parent object'" + o.getClass().getName() + "' expected a TreeItem");
151         }
152     }
153 }
154
155
Popular Tags