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