1   /**
2    * Copyright (c) 2000-2009 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 servletContext,
52              HttpServletRequest request, HttpServletResponse response)
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, servletContext,
59              request, response);
60      }
61  
62      public static void doTag(
63              String page, String align, String allowScriptAccess, String base,
64              String bgcolor, String devicefont, String flashvars, String height,
65              String id, String loop, String menu, String movie, String play,
66              String quality, String salign, String scale, String swliveconnect,
67              String version, String width, String wmode,
68              ServletContext servletContext, HttpServletRequest reqquest,
69              HttpServletResponse response)
70          throws IOException, ServletException {
71  
72          reqquest.setAttribute("liferay-ui:flash:align", align);
73          reqquest.setAttribute(
74              "liferay-ui:flash:allowScriptAccess", allowScriptAccess);
75          reqquest.setAttribute("liferay-ui:flash:base", base);
76          reqquest.setAttribute("liferay-ui:flash:bgcolor", bgcolor);
77          reqquest.setAttribute("liferay-ui:flash:devicefont", devicefont);
78          reqquest.setAttribute("liferay-ui:flash:flashvars", flashvars);
79          reqquest.setAttribute("liferay-ui:flash:height", height);
80          reqquest.setAttribute("liferay-ui:flash:id", id);
81          reqquest.setAttribute("liferay-ui:flash:loop", loop);
82          reqquest.setAttribute("liferay-ui:flash:menu", menu);
83          reqquest.setAttribute("liferay-ui:flash:movie", movie);
84          reqquest.setAttribute("liferay-ui:flash:play", play);
85          reqquest.setAttribute("liferay-ui:flash:quality", quality);
86          reqquest.setAttribute("liferay-ui:flash:salign", salign);
87          reqquest.setAttribute("liferay-ui:flash:scale", scale);
88          reqquest.setAttribute("liferay-ui:flash:swliveconnect", swliveconnect);
89          reqquest.setAttribute("liferay-ui:flash:version", version);
90          reqquest.setAttribute("liferay-ui:flash:width", width);
91          reqquest.setAttribute("liferay-ui:flash:wmode", wmode);
92  
93          RequestDispatcher requestDispatcher =
94              servletContext.getRequestDispatcher(page);
95  
96          requestDispatcher.include(reqquest, response);
97      }
98  
99      public int doEndTag() throws JspException {
100         try {
101             ServletContext servletContext = getServletContext();
102             HttpServletRequest request = getServletRequest();
103             StringServletResponse stringResponse = getServletResponse();
104 
105             doTag(
106                 getPage(), _align, _allowScriptAccess, _base, _bgcolor,
107                 _devicefont, _flashvars, _height, _id, _loop, _menu, _movie,
108                 _play, _quality, _salign, _scale, _swliveconnect, _version,
109                 _width, _wmode, servletContext, request, stringResponse);
110 
111             pageContext.getOut().print(stringResponse.getString());
112 
113             return EVAL_PAGE;
114         }
115         catch (Exception e) {
116             throw new JspException(e);
117         }
118     }
119 
120     public void setAlign(String align) {
121         if (Validator.isNotNull(align)) {
122             _align = align;
123         }
124     }
125 
126     public void setAllowScriptAccess(String allowScriptAccess) {
127         if (Validator.isNotNull(allowScriptAccess)) {
128             _allowScriptAccess = allowScriptAccess;
129         }
130     }
131 
132     public void setBase(String base) {
133         if (Validator.isNotNull(base)) {
134             _base = base;
135         }
136     }
137 
138     public void setBgcolor(String bgcolor) {
139         if (Validator.isNotNull(bgcolor)) {
140             _bgcolor = bgcolor;
141         }
142     }
143 
144     public void setDevicefont(String devicefont) {
145         if (Validator.isNotNull(devicefont)) {
146             _devicefont = devicefont;
147         }
148     }
149 
150     public void setFlashvars(String flashvars) {
151         if (Validator.isNotNull(flashvars)) {
152             _flashvars = flashvars;
153         }
154     }
155 
156     public void setHeight(String height) {
157         if (Validator.isNotNull(height)) {
158             _height = height;
159         }
160     }
161 
162     public void setId(String id) {
163         if (Validator.isNotNull(id)) {
164             _id = id;
165         }
166     }
167 
168     public void setLoop(String loop) {
169         if (Validator.isNotNull(loop)) {
170             _loop = loop;
171         }
172     }
173 
174     public void setMenu(String menu) {
175         if (Validator.isNotNull(menu)) {
176             _menu = menu;
177         }
178     }
179 
180     public void setMovie(String movie) {
181         _movie = movie;
182     }
183 
184     public void setPlay(String play) {
185         if (Validator.isNotNull(play)) {
186             _play = play;
187         }
188     }
189 
190     public void setQuality(String quality) {
191         if (Validator.isNotNull(quality)) {
192             _quality = quality;
193         }
194     }
195 
196     public void setSalign(String salign) {
197         if (Validator.isNotNull(salign)) {
198             _salign = salign;
199         }
200     }
201 
202     public void setScale(String scale) {
203         if (Validator.isNotNull(scale)) {
204             _scale = scale;
205         }
206     }
207 
208     public void setSwliveconnect(String swliveconnect) {
209         if (Validator.isNotNull(swliveconnect)) {
210             _swliveconnect = swliveconnect;
211         }
212     }
213 
214     public void setVersion(String version) {
215         if (Validator.isNotNull(version)) {
216             _version = version;
217         }
218     }
219 
220     public void setWidth(String width) {
221         if (Validator.isNotNull(width)) {
222             _width = width;
223         }
224     }
225 
226     public void setWmode(String wmode) {
227         if (Validator.isNotNull(wmode)) {
228             _wmode = wmode;
229         }
230     }
231 
232     protected String getDefaultPage() {
233         return _PAGE;
234     }
235 
236     private static final String _PAGE = "/html/taglib/ui/flash/page.jsp";
237 
238     private String _align = "left";
239     private String _allowScriptAccess = "sameDomain";
240     private String _base = ".";
241     private String _bgcolor = "#FFFFFF";
242     private String _devicefont = "true";
243     private String _flashvars = "";
244     private String _height = "500";
245     private String _id = "";
246     private String _loop = "true";
247     private String _menu = "false";
248     private String _movie = "";
249     private String _play = "false";
250     private String _quality = "best";
251     private String _salign = "";
252     private String _scale = "showall";
253     private String _swliveconnect = "false";
254     private String _version = "7";
255     private String _width = "100%";
256     private String _wmode = "opaque";
257 
258 }