1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.portal.kernel.servlet.StringServletResponse;
18  import com.liferay.portal.kernel.util.StringPool;
19  import com.liferay.portal.kernel.util.Validator;
20  import com.liferay.taglib.util.IncludeTag;
21  
22  import javax.servlet.RequestDispatcher;
23  import javax.servlet.ServletContext;
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.http.HttpServletResponse;
26  import javax.servlet.jsp.JspException;
27  
28  /**
29   * <a href="FlashTag.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class FlashTag extends IncludeTag {
34  
35      public static void doTag(
36              String align, String allowScriptAccess, String base, String bgcolor,
37              String devicefont, String flashvars, String height, String id,
38              String loop, String menu, String movie, String play, String quality,
39              String salign, String scale, String swliveconnect, String version,
40              String width, String wmode, ServletContext servletContext,
41              HttpServletRequest request, HttpServletResponse response)
42          throws Exception {
43  
44          doTag(
45              _PAGE, align, allowScriptAccess, base, bgcolor, devicefont,
46              flashvars, height, id, loop, menu, movie, play, quality, salign,
47              scale, swliveconnect, version, width, wmode, servletContext,
48              request, response);
49      }
50  
51      public static void doTag(
52              String page, String align, String allowScriptAccess, String base,
53              String bgcolor, String devicefont, String flashvars, String height,
54              String id, String loop, String menu, String movie, String play,
55              String quality, String salign, String scale, String swliveconnect,
56              String version, String width, String wmode,
57              ServletContext servletContext, HttpServletRequest reqquest,
58              HttpServletResponse response)
59          throws Exception {
60  
61          reqquest.setAttribute("liferay-ui:flash:align", align);
62          reqquest.setAttribute(
63              "liferay-ui:flash:allowScriptAccess", allowScriptAccess);
64          reqquest.setAttribute("liferay-ui:flash:base", base);
65          reqquest.setAttribute("liferay-ui:flash:bgcolor", bgcolor);
66          reqquest.setAttribute("liferay-ui:flash:devicefont", devicefont);
67          reqquest.setAttribute("liferay-ui:flash:flashvars", flashvars);
68          reqquest.setAttribute("liferay-ui:flash:height", height);
69          reqquest.setAttribute("liferay-ui:flash:id", id);
70          reqquest.setAttribute("liferay-ui:flash:loop", loop);
71          reqquest.setAttribute("liferay-ui:flash:menu", menu);
72          reqquest.setAttribute("liferay-ui:flash:movie", movie);
73          reqquest.setAttribute("liferay-ui:flash:play", play);
74          reqquest.setAttribute("liferay-ui:flash:quality", quality);
75          reqquest.setAttribute("liferay-ui:flash:salign", salign);
76          reqquest.setAttribute("liferay-ui:flash:scale", scale);
77          reqquest.setAttribute("liferay-ui:flash:swliveconnect", swliveconnect);
78          reqquest.setAttribute("liferay-ui:flash:version", version);
79          reqquest.setAttribute("liferay-ui:flash:width", width);
80          reqquest.setAttribute("liferay-ui:flash:wmode", wmode);
81  
82          RequestDispatcher requestDispatcher =
83              servletContext.getRequestDispatcher(page);
84  
85          requestDispatcher.include(reqquest, response);
86      }
87  
88      public int doEndTag() throws JspException {
89          try {
90              ServletContext servletContext = getServletContext();
91              HttpServletRequest request = getServletRequest();
92              StringServletResponse stringResponse = getServletResponse();
93  
94              doTag(
95                  getPage(), _align, _allowScriptAccess, _base, _bgcolor,
96                  _devicefont, _flashvars, _height, _id, _loop, _menu, _movie,
97                  _play, _quality, _salign, _scale, _swliveconnect, _version,
98                  _width, _wmode, servletContext, request, stringResponse);
99  
100             pageContext.getOut().print(stringResponse.getString());
101 
102             return EVAL_PAGE;
103         }
104         catch (Exception e) {
105             throw new JspException(e);
106         }
107     }
108 
109     public void setAlign(String align) {
110         if (Validator.isNotNull(align)) {
111             _align = align;
112         }
113     }
114 
115     public void setAllowScriptAccess(String allowScriptAccess) {
116         if (Validator.isNotNull(allowScriptAccess)) {
117             _allowScriptAccess = allowScriptAccess;
118         }
119     }
120 
121     public void setBase(String base) {
122         if (Validator.isNotNull(base)) {
123             _base = base;
124         }
125     }
126 
127     public void setBgcolor(String bgcolor) {
128         if (Validator.isNotNull(bgcolor)) {
129             _bgcolor = bgcolor;
130         }
131     }
132 
133     public void setDevicefont(String devicefont) {
134         if (Validator.isNotNull(devicefont)) {
135             _devicefont = devicefont;
136         }
137     }
138 
139     public void setFlashvars(String flashvars) {
140         if (Validator.isNotNull(flashvars)) {
141             _flashvars = flashvars;
142         }
143     }
144 
145     public void setHeight(String height) {
146         if (Validator.isNotNull(height)) {
147             _height = height;
148         }
149     }
150 
151     public void setId(String id) {
152         if (Validator.isNotNull(id)) {
153             _id = id;
154         }
155     }
156 
157     public void setLoop(String loop) {
158         if (Validator.isNotNull(loop)) {
159             _loop = loop;
160         }
161     }
162 
163     public void setMenu(String menu) {
164         if (Validator.isNotNull(menu)) {
165             _menu = menu;
166         }
167     }
168 
169     public void setMovie(String movie) {
170         _movie = movie;
171     }
172 
173     public void setPlay(String play) {
174         if (Validator.isNotNull(play)) {
175             _play = play;
176         }
177     }
178 
179     public void setQuality(String quality) {
180         if (Validator.isNotNull(quality)) {
181             _quality = quality;
182         }
183     }
184 
185     public void setSalign(String salign) {
186         if (Validator.isNotNull(salign)) {
187             _salign = salign;
188         }
189     }
190 
191     public void setScale(String scale) {
192         if (Validator.isNotNull(scale)) {
193             _scale = scale;
194         }
195     }
196 
197     public void setSwliveconnect(String swliveconnect) {
198         if (Validator.isNotNull(swliveconnect)) {
199             _swliveconnect = swliveconnect;
200         }
201     }
202 
203     public void setVersion(String version) {
204         if (Validator.isNotNull(version)) {
205             _version = version;
206         }
207     }
208 
209     public void setWidth(String width) {
210         if (Validator.isNotNull(width)) {
211             _width = width;
212         }
213     }
214 
215     public void setWmode(String wmode) {
216         if (Validator.isNotNull(wmode)) {
217             _wmode = wmode;
218         }
219     }
220 
221     protected String getDefaultPage() {
222         return _PAGE;
223     }
224 
225     private static final String _PAGE = "/html/taglib/ui/flash/page.jsp";
226 
227     private String _align = "left";
228     private String _allowScriptAccess = "sameDomain";
229     private String _base = StringPool.PERIOD;
230     private String _bgcolor = "#FFFFFF";
231     private String _devicefont = Boolean.TRUE.toString();
232     private String _flashvars = StringPool.BLANK;
233     private String _height = "500";
234     private String _id = StringPool.BLANK;
235     private String _loop = Boolean.TRUE.toString();
236     private String _menu = Boolean.FALSE.toString();
237     private String _movie = StringPool.BLANK;
238     private String _play = Boolean.FALSE.toString();
239     private String _quality = "best";
240     private String _salign = StringPool.BLANK;
241     private String _scale = "showall";
242     private String _swliveconnect = Boolean.FALSE.toString();
243     private String _version = "7";
244     private String _width = "100%";
245     private String _wmode = "opaque";
246 
247 }