1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.taglib.ui;
21  
22  import com.liferay.portal.kernel.servlet.StringServletResponse;
23  import com.liferay.portal.kernel.util.Validator;
24  import com.liferay.taglib.util.IncludeTag;
25  
26  import java.io.IOException;
27  
28  import javax.servlet.RequestDispatcher;
29  import javax.servlet.ServletContext;
30  import javax.servlet.ServletException;
31  import javax.servlet.http.HttpServletRequest;
32  import javax.servlet.http.HttpServletResponse;
33  import javax.servlet.jsp.JspException;
34  
35  /**
36   * <a href="FlashTag.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Brian Wing Shun Chan
39   *
40   */
41  public class FlashTag extends IncludeTag {
42  
43      public static void doTag(
44              String align, String allowScriptAccess, String base, String bgcolor,
45              String devicefont, String flashvars, String height, String id,
46              String loop, String menu, String movie, String play, String quality,
47              String salign, String scale, String swliveconnect, String version,
48              String width, String wmode, ServletContext servletContext,
49              HttpServletRequest request, HttpServletResponse response)
50          throws IOException, ServletException {
51  
52          doTag(
53              _PAGE, align, allowScriptAccess, base, bgcolor, devicefont,
54              flashvars, height, id, loop, menu, movie, play, quality, salign,
55              scale, swliveconnect, version, width, wmode, servletContext,
56              request, response);
57      }
58  
59      public static void doTag(
60              String page, String align, String allowScriptAccess, String base,
61              String bgcolor, String devicefont, String flashvars, String height,
62              String id, String loop, String menu, String movie, String play,
63              String quality, String salign, String scale, String swliveconnect,
64              String version, String width, String wmode,
65              ServletContext servletContext, HttpServletRequest reqquest,
66              HttpServletResponse response)
67          throws IOException, ServletException {
68  
69          reqquest.setAttribute("liferay-ui:flash:align", align);
70          reqquest.setAttribute(
71              "liferay-ui:flash:allowScriptAccess", allowScriptAccess);
72          reqquest.setAttribute("liferay-ui:flash:base", base);
73          reqquest.setAttribute("liferay-ui:flash:bgcolor", bgcolor);
74          reqquest.setAttribute("liferay-ui:flash:devicefont", devicefont);
75          reqquest.setAttribute("liferay-ui:flash:flashvars", flashvars);
76          reqquest.setAttribute("liferay-ui:flash:height", height);
77          reqquest.setAttribute("liferay-ui:flash:id", id);
78          reqquest.setAttribute("liferay-ui:flash:loop", loop);
79          reqquest.setAttribute("liferay-ui:flash:menu", menu);
80          reqquest.setAttribute("liferay-ui:flash:movie", movie);
81          reqquest.setAttribute("liferay-ui:flash:play", play);
82          reqquest.setAttribute("liferay-ui:flash:quality", quality);
83          reqquest.setAttribute("liferay-ui:flash:salign", salign);
84          reqquest.setAttribute("liferay-ui:flash:scale", scale);
85          reqquest.setAttribute("liferay-ui:flash:swliveconnect", swliveconnect);
86          reqquest.setAttribute("liferay-ui:flash:version", version);
87          reqquest.setAttribute("liferay-ui:flash:width", width);
88          reqquest.setAttribute("liferay-ui:flash:wmode", wmode);
89  
90          RequestDispatcher requestDispatcher =
91              servletContext.getRequestDispatcher(page);
92  
93          requestDispatcher.include(reqquest, response);
94      }
95  
96      public int doEndTag() throws JspException {
97          try {
98              ServletContext servletContext = getServletContext();
99              HttpServletRequest request = getServletRequest();
100             StringServletResponse stringResponse = getServletResponse();
101 
102             doTag(
103                 getPage(), _align, _allowScriptAccess, _base, _bgcolor,
104                 _devicefont, _flashvars, _height, _id, _loop, _menu, _movie,
105                 _play, _quality, _salign, _scale, _swliveconnect, _version,
106                 _width, _wmode, servletContext, request, stringResponse);
107 
108             pageContext.getOut().print(stringResponse.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 }