KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > deprecated > taglibs > button > TabButtonTag


1 package org.jahia.deprecated.taglibs.button;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
5
6 /**
7  * Declare a new Tab Button. Must be enclosed inside a TabButtonsListTag
8  *
9  * @see TabButtonsListTag
10  * @author Khue Nguyuen
11  */

12
13 public class TabButtonTag extends TagSupport JavaDoc {
14
15     private static org.apache.log4j.Logger logger =
16             org.apache.log4j.Logger.getLogger(TabButtonTag.class);
17
18     private String JavaDoc label = "";
19     private String JavaDoc labelKey = null;
20     private String JavaDoc labelBundle = null;
21     private String JavaDoc url = "#";
22     private boolean isSelected = false;
23
24     public void setLabel(String JavaDoc label) {
25         logger.debug("Setting label..");
26         this.label = label;
27     }
28
29     public void setLabelKey(String JavaDoc labelKey) {
30         this.labelKey = labelKey;
31     }
32
33     public void setLabelBundle(String JavaDoc labelBundle) {
34         this.labelBundle = labelBundle;
35     }
36
37     public void setUrl(String JavaDoc url) {
38         this.url = url;
39     }
40
41     public void setIsSelected(String JavaDoc val) {
42         try {
43             isSelected = val.toLowerCase().equals("true");
44         } catch ( Throwable JavaDoc t ){
45             logger.debug("exception :" + t.getMessage() );
46         }
47     }
48
49     public String JavaDoc getLabel() {
50         return this.label;
51     }
52
53     public String JavaDoc getLabelKey() {
54         return this.labelKey;
55     }
56
57     public String JavaDoc getLabelBundle() {
58         return this.labelBundle;
59     }
60
61     public String JavaDoc getUrl() {
62         return this.url;
63     }
64
65     public String JavaDoc getIsSelected() {
66         return (isSelected?"true":"false");
67     }
68
69     public int doStartTag() {
70
71         logger.debug("Started");
72
73         // gets the enclosing tag
74
TabButtonsListTag tabButtonsListTag = (TabButtonsListTag) findAncestorWithClass(this, TabButtonsListTag.class);
75         if (tabButtonsListTag != null) {
76             tabButtonsListTag.addTabButton(getUrl(),getLabel(),getLabelKey(), getLabelBundle(), isSelected);
77         }
78         return SKIP_BODY;
79     }
80
81     public int doEndTag() throws JspException JavaDoc {
82         // let's reinitialize the tag variables to allow tag object reuse in
83
// pooling.
84
label = "";
85         labelKey = null;
86         labelBundle = null;
87         url = "#";
88         isSelected = false;
89         return EVAL_PAGE;
90     }
91
92 }
Popular Tags