KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > html > FrameTag


1 /*
2  * $Id: FrameTag.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.struts.taglib.html;
20
21 import javax.servlet.jsp.JspException JavaDoc;
22
23 import org.apache.struts.taglib.TagUtils;
24
25 /**
26  * Generate an HTML <code>&lt;frame&gt;</code> tag with similar capabilities
27  * as those the <code>&lt;html:link&gt;</code> tag provides for hyperlink
28  * elements. The <code>src</code> element is rendered using the same technique
29  * that {@link LinkTag} uses to render the <code>href</code> attribute of a
30  * hyperlink. Additionall, the HTML 4.0
31  * frame tag attributes <code>noresize</code>, <code>scrolling</code>,
32  * <code>marginheight</code>, <code>marginwidth</code>,
33  * <code>frameborder</code>, and <code>longdesc</code> are supported.
34  * The frame
35  * <code>name</code> attribute is rendered based on the <code>frameName</code>
36  * property.
37  *
38  * Note that the value of <code>longdesc</code> is intended to be a URI, but
39  * currently no rewriting is supported. The attribute is set directly from
40  * the property value.
41  *
42  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
43  * @since Struts 1.1
44  */

45 public class FrameTag extends LinkTag {
46
47
48     // ------------------------------------------------------------- Properties
49

50
51     /**
52      * The frameborder attribute that should be rendered (1, 0).
53      */

54     protected String JavaDoc frameborder = null;
55
56     public String JavaDoc getFrameborder() {
57         return (this.frameborder);
58     }
59
60     public void setFrameborder(String JavaDoc frameborder) {
61         this.frameborder = frameborder;
62     }
63
64
65     /**
66      * The <code>name</code> attribute that should be rendered for this frame.
67      */

68     protected String JavaDoc frameName = null;
69
70     public String JavaDoc getFrameName() {
71         return (this.frameName);
72     }
73
74     public void setFrameName(String JavaDoc frameName) {
75         this.frameName = frameName;
76     }
77
78
79     /**
80      * URI of a long description of this frame (complements title).
81      */

82     protected String JavaDoc longdesc = null;
83
84     public String JavaDoc getLongdesc() {
85         return (this.longdesc);
86     }
87
88     public void setLongdesc(String JavaDoc longdesc) {
89         this.longdesc = longdesc;
90     }
91
92
93     /**
94      * The margin height in pixels, or zero for no setting.
95      */

96     protected Integer JavaDoc marginheight = null;
97
98     public Integer JavaDoc getMarginheight() {
99         return (this.marginheight);
100     }
101
102     public void setMarginheight(Integer JavaDoc marginheight) {
103         this.marginheight = marginheight;
104     }
105
106
107     /**
108      * The margin width in pixels, or null for no setting.
109      */

110     protected Integer JavaDoc marginwidth = null;
111
112     public Integer JavaDoc getMarginwidth() {
113         return (this.marginwidth);
114     }
115
116     public void setMarginwidth(Integer JavaDoc marginwidth) {
117         this.marginwidth = marginwidth;
118     }
119
120
121     /**
122      * Should users be disallowed to resize the frame?
123      */

124     protected boolean noresize = false;
125
126     public boolean getNoresize() {
127         return (this.noresize);
128     }
129
130     public void setNoresize(boolean noresize) {
131         this.noresize = noresize;
132     }
133
134
135     /**
136      * What type of scrolling should be supported (yes, no, auto)?
137      */

138     protected String JavaDoc scrolling = null;
139
140     public String JavaDoc getScrolling() {
141         return (this.scrolling);
142     }
143
144     public void setScrolling(String JavaDoc scrolling) {
145         this.scrolling = scrolling;
146     }
147
148
149     // --------------------------------------------------------- Public Methods
150

151
152     /**
153      * Render the appropriately encoded URI.
154      *
155      * @exception JspException if a JSP exception has occurred
156      */

157     public int doStartTag() throws JspException JavaDoc {
158
159     // Print this element to our output writer
160
StringBuffer JavaDoc results = new StringBuffer JavaDoc("<frame");
161
162         prepareAttribute(results, "src", calculateURL());
163         prepareAttribute(results, "name", getFrameName());
164
165         if (noresize) {
166             results.append(" noresize=\"noresize\"");
167         }
168         prepareAttribute(results, "scrolling", getScrolling());
169         prepareAttribute(results, "marginheight", getMarginheight());
170         prepareAttribute(results, "marginwidth", getMarginwidth());
171         prepareAttribute(results, "frameborder", getFrameborder());
172         prepareAttribute(results, "longdesc", getLongdesc());
173         results.append(prepareStyles());
174         prepareOtherAttributes(results);
175         results.append(getElementClose());
176         TagUtils.getInstance().write(pageContext,results.toString());
177
178         return (SKIP_BODY);
179
180     }
181
182
183     /**
184      * Ignore the end of this tag.
185      *
186      * @exception JspException if a JSP exception has occurred
187      */

188     public int doEndTag() throws JspException JavaDoc {
189
190         return (EVAL_PAGE);
191
192     }
193
194
195     /**
196      * Release any acquired resources.
197      */

198     public void release() {
199
200         super.release();
201         frameborder = null;
202         frameName = null;
203         longdesc = null;
204         marginheight = null;
205         marginwidth = null;
206         noresize = false;
207         scrolling = null;
208
209     }
210
211
212 }
213
Popular Tags