1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.taglib.html;
19
20 import org.apache.struts.taglib.TagUtils;
21
22 import javax.servlet.jsp.JspException;
23
24 /***
25 * Generate an HTML <code><frame></code> tag with similar capabilities
26 * as those the <code><html:link></code> tag provides for hyperlink
27 * elements. The <code>src</code> element is rendered using the same
28 * technique that {@link LinkTag} uses to render the <code>href</code>
29 * attribute of a hyperlink. Additionall, the HTML 4.0 frame tag attributes
30 * <code>noresize</code>, <code>scrolling</code>, <code>marginheight</code>,
31 * <code>marginwidth</code>, <code>frameborder</code>, and
32 * <code>longdesc</code> are supported. The frame <code>name</code> attribute
33 * is rendered based on the <code>frameName</code> property.
34 *
35 * Note that the value of <code>longdesc</code> is intended to be a URI, but
36 * currently no rewriting is supported. The attribute is set directly from
37 * the property value.
38 *
39 * @version $Rev: 376841 $ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
40 * $
41 * @since Struts 1.1
42 */
43 public class FrameTag extends LinkTag {
44
45
46 /***
47 * The frameborder attribute that should be rendered (1, 0).
48 */
49 protected String frameborder = null;
50
51 /***
52 * The <code>name</code> attribute that should be rendered for this
53 * frame.
54 */
55 protected String frameName = null;
56
57 /***
58 * URI of a long description of this frame (complements title).
59 */
60 protected String longdesc = null;
61
62 /***
63 * The margin height in pixels, or zero for no setting.
64 */
65 protected Integer marginheight = null;
66
67 /***
68 * The margin width in pixels, or null for no setting.
69 */
70 protected Integer marginwidth = null;
71
72 /***
73 * Should users be disallowed to resize the frame?
74 */
75 protected boolean noresize = false;
76
77 /***
78 * What type of scrolling should be supported (yes, no, auto)?
79 */
80 protected String scrolling = null;
81
82 public String getFrameborder() {
83 return (this.frameborder);
84 }
85
86 public void setFrameborder(String frameborder) {
87 this.frameborder = frameborder;
88 }
89
90 public String getFrameName() {
91 return (this.frameName);
92 }
93
94 public void setFrameName(String frameName) {
95 this.frameName = frameName;
96 }
97
98 public String getLongdesc() {
99 return (this.longdesc);
100 }
101
102 public void setLongdesc(String longdesc) {
103 this.longdesc = longdesc;
104 }
105
106 public Integer getMarginheight() {
107 return (this.marginheight);
108 }
109
110 public void setMarginheight(Integer marginheight) {
111 this.marginheight = marginheight;
112 }
113
114 public Integer getMarginwidth() {
115 return (this.marginwidth);
116 }
117
118 public void setMarginwidth(Integer marginwidth) {
119 this.marginwidth = marginwidth;
120 }
121
122 public boolean getNoresize() {
123 return (this.noresize);
124 }
125
126 public void setNoresize(boolean noresize) {
127 this.noresize = noresize;
128 }
129
130 public String getScrolling() {
131 return (this.scrolling);
132 }
133
134 public void setScrolling(String scrolling) {
135 this.scrolling = scrolling;
136 }
137
138
139
140 /***
141 * Render the appropriately encoded URI.
142 *
143 * @throws JspException if a JSP exception has occurred
144 */
145 public int doStartTag() throws JspException {
146
147 StringBuffer results = new StringBuffer("<frame");
148
149 prepareAttribute(results, "src", calculateURL());
150 prepareAttribute(results, "name", getFrameName());
151
152 if (noresize) {
153 results.append(" noresize=\"noresize\"");
154 }
155
156 prepareAttribute(results, "scrolling", getScrolling());
157 prepareAttribute(results, "marginheight", getMarginheight());
158 prepareAttribute(results, "marginwidth", getMarginwidth());
159 prepareAttribute(results, "frameborder", getFrameborder());
160 prepareAttribute(results, "longdesc", getLongdesc());
161 results.append(prepareStyles());
162 prepareOtherAttributes(results);
163 results.append(getElementClose());
164 TagUtils.getInstance().write(pageContext, results.toString());
165
166 return (SKIP_BODY);
167 }
168
169 /***
170 * Ignore the end of this tag.
171 *
172 * @throws JspException if a JSP exception has occurred
173 */
174 public int doEndTag() throws JspException {
175 return (EVAL_PAGE);
176 }
177
178 /***
179 * Release any acquired resources.
180 */
181 public void release() {
182 super.release();
183 frameborder = null;
184 frameName = null;
185 longdesc = null;
186 marginheight = null;
187 marginwidth = null;
188 noresize = false;
189 scrolling = null;
190 }
191 }