01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.tags.tree;
20:
21: import org.apache.beehive.netui.tags.AbstractSimpleTag;
22: import org.apache.beehive.netui.util.logging.Logger;
23:
24: import javax.servlet.jsp.JspException;
25: import java.io.IOException;
26:
27: /**
28: * @jsptagref.tagdescription Set the additional content that will be displayed on the right of the label of a tree.
29: * @example The following example shows a <netui:tree> tag with both a
30: * child <netui:treeLabel> and <netui:treeContent> tag that form the
31: * label and the additional text displayed to the righ of the label for the
32: * root folder of the tree.
33: *
34: * <pre> <netui:tree dataSource="pageFlow.myTree" selectionAction="postback" tagId="myTree">
35: * <netui:treeItem expanded="true" >
36: * <netui:treeLabel>Root Folder</netui:treeLabel>
37: * <netui:treeContent>Content to right of label: Root Folder</netui:treeContent>
38: * </netui:treeItem>
39: * </netui:tree></pre>
40: * @netui:tag name="treeContent" body-content="scriptless"
41: * description="Set the additional content that will be displayed on the right of the label of a tree."
42: * @see org.apache.beehive.netui.tags.tree.Tree
43: * @see org.apache.beehive.netui.tags.tree.TreeElement
44: */
45: public class TreeContent extends AbstractSimpleTag {
46: private static final Logger logger = Logger
47: .getInstance(TreeContent.class);
48: private String _text;
49:
50: /**
51: * Return the name of the Tag.
52: */
53: public String getTagName() {
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() throws JspException, IOException {
62: String value = getBufferBody(true);
63: if (value != null)
64: _text = value;
65:
66: Object o = getParent();
67: assert (o != null);
68: if (!(o instanceof TreeItem)) {
69: logger.error("Invalid Parent (expected a TreeItem):"
70: + o.getClass().getName());
71: return;
72: }
73:
74: // assign the value to the parent's label value
75: TreeItem ti = (TreeItem) o;
76: ti.setItemContent(_text);
77: }
78: }
|