KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lamatek > tags > google > GoogleMapTabTag


1 package com.lamatek.tags.google;
2
3 import java.io.Serializable JavaDoc;
4
5 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
6 import javax.servlet.jsp.tagext.Tag JavaDoc;
7
8 import com.lamatek.tags.google.beans.EscapeChars;
9
10 /**
11  * GoogleMapTabTag
12  *
13  * This tag represents a <googlemaps:tab> tag, which is a child to <googlemaps:tabbedInfoWindow> tag.
14  * Developers should not extend this class or override it's methods.
15  *
16  * @author Tom Cole
17  * @version 0.87
18  */

19 public class GoogleMapTabTag extends BodyTagSupport JavaDoc implements Serializable JavaDoc {
20
21     String JavaDoc label = null;
22     String JavaDoc content = null;
23     boolean html = true;
24     /**
25      * Overrides doStartTag() from BodyTagSupport.
26      */

27     public int doStartTag() {
28         return EVAL_BODY_BUFFERED;
29     }
30     /**
31      * Overrides doEndTag from BodyTagSupport.
32      */

33     public int doEndTag() {
34         if (content == null) {
35             content = getBodyContent().getString().trim();
36             if (html)
37                 content = EscapeChars.escape(content);
38         }
39         Tag JavaDoc tag = this;
40         while (tag.getParent() != null) {
41             if (tag.getParent() instanceof GoogleMapInfoWindowTabbedTag) {
42                 ((GoogleMapInfoWindowTabbedTag) tag.getParent()).addTab(this);
43                 return EVAL_PAGE;
44             }
45             tag = tag.getParent();
46         }
47         return EVAL_PAGE;
48     }
49     /**
50      * Returns the label for this tab. The label is the clickable text that is
51      * displayed on a tab to show it's contents.
52      *
53      * @return The label for this tab.
54      */

55     public String JavaDoc getLabel() {
56         return label;
57     }
58     /**
59      * Sets the label for this tab. The label is the clickable text that is
60      * displayed on a tab to show it's contents.
61      *
62      * @param label The label for this tab.
63      */

64     public void setLabel(String JavaDoc label) {
65         this.label = label;
66     }
67     /**
68      * Returns the displayable contents of this tab. This can be HTML or plain text.
69      * These contents are displayed when this tab is clicked.
70      *
71      * @return The contents of this tab.
72      */

73     public String JavaDoc getContent() {
74         return content;
75     }
76     /**
77      * Sets the displayable contents of this tab. This can be HTML or plain text.
78      * These contents will be displayed when this tab is clicked. If this is set,
79      * the content between the starting tag and ending tag will be ignored.
80      *
81      * @param content The contents of this tab.
82      */

83     public void setContent(String JavaDoc content) {
84         if (html) {
85             this.content = EscapeChars.escape(content.trim());
86         }
87         else {
88             this.content = content.trim();
89         }
90     }
91     /**
92      * Denotes whether or not the contents of this tag are html and therefore
93      * need to be escaped.
94      *
95      * @return True or false.
96      */

97     public boolean isHtml() {
98         return html;
99     }
100     /**
101      * Sets whether or not the contents of this tag are html and therefore need
102      * to be escaped.
103      *
104      * @param html True if content needs to be escaped, false if not.
105      */

106     public void setHtml(boolean html) {
107         this.html = html;
108     }
109 }
110
Popular Tags