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 text displayed for the selection link the given tree node (the TreeItem tag).
29: *
30: * <p>Note that a <code><netui:treeLabel></code> tag is required for all non-leaf nodes in the tree.</p>
31: * @netui:tag name="treeLabel" body-content="scriptless" description="Set the label for the parent TreeItem."
32: * @see org.apache.beehive.netui.tags.tree.Tree
33: * @see org.apache.beehive.netui.tags.tree.TreeElement
34: */
35: public class TreeLabel extends AbstractSimpleTag {
36: private static final Logger logger = Logger
37: .getInstance(TreeLabel.class);
38:
39: private String _text;
40:
41: /**
42: * Return the name of the Tag.
43: */
44: public String getTagName() {
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() throws JspException, IOException {
53: String value = getBufferBody(true);
54: if (value.length() > 0)
55: _text = value;
56:
57: Object o = getParent();
58: assert (o != null);
59: if (!(o instanceof TreeItem)) {
60: logger.error("Invalid Parent (expected a TreeItem):"
61: + o.getClass().getName());
62: return;
63: }
64:
65: // assign the value to the parent's label value
66: TreeItem ti = (TreeItem) o;
67: ti.setItemLabel(_text);
68: }
69: }
|