| ToggleValueTag.java |
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.util.StringPool;
18 import com.liferay.portal.util.SessionClicks;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.jsp.JspException;
22 import javax.servlet.jsp.PageContext;
23 import javax.servlet.jsp.tagext.TagSupport;
24
25 /**
26 * <a href="ToggleValueTag.java.html"><b><i>View Source</i></b></a>
27 *
28 * @author Brian Wing Shun Chan
29 */
30 public class ToggleValueTag extends TagSupport {
31
32 public static void doTag(String id, PageContext pageContext)
33 throws Exception {
34
35 HttpServletRequest request =
36 (HttpServletRequest)pageContext.getRequest();
37
38 String value = SessionClicks.get(request, id, StringPool.BLANK);
39
40 if (value.equals(StringPool.BLANK)) {
41 value = "block";
42 }
43
44 pageContext.getOut().print(value);
45 }
46
47 /**
48 * @deprecated
49 */
50 public static void doTag(
51 String id, PageContext pageContext, HttpServletRequest request)
52 throws Exception {
53
54 doTag(id, pageContext);
55 }
56
57 public int doEndTag() throws JspException {
58 try {
59 doTag(_id, pageContext);
60
61 return EVAL_PAGE;
62 }
63 catch (Exception e) {
64 throw new JspException(e);
65 }
66 }
67
68 public void setId(String id) {
69 _id = id;
70 }
71
72 private String _id;
73
74 }