1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
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  }