1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.taglib.ui;
24  
25  import com.liferay.portal.kernel.servlet.StringServletResponse;
26  import com.liferay.portal.kernel.util.Validator;
27  import com.liferay.taglib.util.IncludeTag;
28  
29  import java.io.IOException;
30  
31  import javax.servlet.RequestDispatcher;
32  import javax.servlet.ServletContext;
33  import javax.servlet.ServletException;
34  import javax.servlet.http.HttpServletRequest;
35  import javax.servlet.http.HttpServletResponse;
36  import javax.servlet.jsp.JspException;
37  
38  /**
39   * <a href="FlashTag.java.html"><b><i>View Source</i></b></a>
40   *
41   * @author Brian Wing Shun Chan
42   *
43   */
44  public class FlashTag extends IncludeTag {
45  
46      public static void doTag(
47              String align, String allowScriptAccess, String base, String bgcolor,
48              String devicefont, String flashvars, String height, String id,
49              String loop, String menu, String movie, String play, String quality,
50              String salign, String scale, String swliveconnect, String version,
51              String width, String wmode, ServletContext ctx,
52              HttpServletRequest req, HttpServletResponse res)
53          throws IOException, ServletException {
54  
55          doTag(
56              _PAGE, align, allowScriptAccess, base, bgcolor, devicefont,
57              flashvars, height, id, loop, menu, movie, play, quality, salign,
58              scale, swliveconnect, version, width, wmode, ctx, req, res);
59      }
60  
61      public static void doTag(
62              String page, String align, String allowScriptAccess, String base,
63              String bgcolor, String devicefont, String flashvars, String height,
64              String id, String loop, String menu, String movie, String play,
65              String quality, String salign, String scale, String swliveconnect,
66              String version, String width, String wmode, ServletContext ctx,
67              HttpServletRequest req, HttpServletResponse res)
68          throws IOException, ServletException {
69  
70          req.setAttribute("liferay-ui:flash:align", align);
71          req.setAttribute(
72              "liferay-ui:flash:allowScriptAccess", allowScriptAccess);
73          req.setAttribute("liferay-ui:flash:base", base);
74          req.setAttribute("liferay-ui:flash:bgcolor", bgcolor);
75          req.setAttribute("liferay-ui:flash:devicefont", devicefont);
76          req.setAttribute("liferay-ui:flash:flashvars", flashvars);
77          req.setAttribute("liferay-ui:flash:height", height);
78          req.setAttribute("liferay-ui:flash:id", id);
79          req.setAttribute("liferay-ui:flash:loop", loop);
80          req.setAttribute("liferay-ui:flash:menu", menu);
81          req.setAttribute("liferay-ui:flash:movie", movie);
82          req.setAttribute("liferay-ui:flash:play", play);
83          req.setAttribute("liferay-ui:flash:quality", quality);
84          req.setAttribute("liferay-ui:flash:salign", salign);
85          req.setAttribute("liferay-ui:flash:scale", scale);
86          req.setAttribute("liferay-ui:flash:swliveconnect", swliveconnect);
87          req.setAttribute("liferay-ui:flash:version", version);
88          req.setAttribute("liferay-ui:flash:width", width);
89          req.setAttribute("liferay-ui:flash:wmode", wmode);
90  
91          RequestDispatcher rd = ctx.getRequestDispatcher(page);
92  
93          rd.include(req, res);
94      }
95  
96      public int doEndTag() throws JspException {
97          try {
98              ServletContext ctx = getServletContext();
99              HttpServletRequest req = getServletRequest();
100             StringServletResponse res = getServletResponse();
101 
102             doTag(
103                 _align, _allowScriptAccess, _base, _bgcolor, _devicefont,
104                 _flashvars, _height, _id, _loop, _menu, _movie, _play, _quality,
105                 _salign, _scale, _swliveconnect, _version, _width, _wmode, ctx,
106                 req, res);
107 
108             pageContext.getOut().print(res.getString());
109 
110             return EVAL_PAGE;
111         }
112         catch (Exception e) {
113             throw new JspException(e);
114         }
115     }
116 
117     public void setAlign(String align) {
118         if (Validator.isNotNull(align)) {
119             _align = align;
120         }
121     }
122 
123     public void setAllowScriptAccess(String allowScriptAccess) {
124         if (Validator.isNotNull(allowScriptAccess)) {
125             _allowScriptAccess = allowScriptAccess;
126         }
127     }
128 
129     public void setBase(String base) {
130         if (Validator.isNotNull(base)) {
131             _base = base;
132         }
133     }
134 
135     public void setBgcolor(String bgcolor) {
136         if (Validator.isNotNull(bgcolor)) {
137             _bgcolor = bgcolor;
138         }
139     }
140 
141     public void setDevicefont(String devicefont) {
142         if (Validator.isNotNull(devicefont)) {
143             _devicefont = devicefont;
144         }
145     }
146 
147     public void setFlashvars(String flashvars) {
148         if (Validator.isNotNull(flashvars)) {
149             _flashvars = flashvars;
150         }
151     }
152 
153     public void setHeight(String height) {
154         if (Validator.isNotNull(height)) {
155             _height = height;
156         }
157     }
158 
159     public void setId(String id) {
160         if (Validator.isNotNull(id)) {
161             _id = id;
162         }
163     }
164 
165     public void setLoop(String loop) {
166         if (Validator.isNotNull(loop)) {
167             _loop = loop;
168         }
169     }
170 
171     public void setMenu(String menu) {
172         if (Validator.isNotNull(menu)) {
173             _menu = menu;
174         }
175     }
176 
177     public void setMovie(String movie) {
178         _movie = movie;
179     }
180 
181     public void setPlay(String play) {
182         if (Validator.isNotNull(play)) {
183             _play = play;
184         }
185     }
186 
187     public void setQuality(String quality) {
188         if (Validator.isNotNull(quality)) {
189             _quality = quality;
190         }
191     }
192 
193     public void setSalign(String salign) {
194         if (Validator.isNotNull(salign)) {
195             _salign = salign;
196         }
197     }
198 
199     public void setScale(String scale) {
200         if (Validator.isNotNull(scale)) {
201             _scale = scale;
202         }
203     }
204 
205     public void setSwliveconnect(String swliveconnect) {
206         if (Validator.isNotNull(swliveconnect)) {
207             _swliveconnect = swliveconnect;
208         }
209     }
210 
211     public void setVersion(String version) {
212         if (Validator.isNotNull(version)) {
213             _version = version;
214         }
215     }
216 
217     public void setWidth(String width) {
218         if (Validator.isNotNull(width)) {
219             _width = width;
220         }
221     }
222 
223     public void setWmode(String wmode) {
224         if (Validator.isNotNull(wmode)) {
225             _wmode = wmode;
226         }
227     }
228 
229     protected String getDefaultPage() {
230         return _PAGE;
231     }
232 
233     private static final String _PAGE = "/html/taglib/ui/flash/page.jsp";
234 
235     private String _align = "left";
236     private String _allowScriptAccess = "sameDomain";
237     private String _base = ".";
238     private String _bgcolor = "#FFFFFF";
239     private String _devicefont = "true";
240     private String _flashvars = "";
241     private String _height = "500";
242     private String _id = "";
243     private String _loop = "true";
244     private String _menu = "false";
245     private String _movie = "";
246     private String _play = "false";
247     private String _quality = "best";
248     private String _salign = "";
249     private String _scale = "showall";
250     private String _swliveconnect = "false";
251     private String _version = "7";
252     private String _width = "100%";
253     private String _wmode = "opaque";
254 
255 }