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.aui;
16  
17  import com.liferay.portal.kernel.util.Validator;
18  import com.liferay.taglib.util.IncludeTag;
19  
20  import javax.servlet.http.HttpServletRequest;
21  
22  /**
23   * <a href="OptionTag.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Julio Camarero
26   * @author Jorge Ferrer
27   * @author Brian Wing Shun Chan
28   */
29  public class OptionTag extends IncludeTag {
30  
31      public void setCssClass(String cssClass) {
32          _cssClass = cssClass;
33      }
34  
35      public void setLabel(Object label) {
36          _label = String.valueOf(label);
37      }
38  
39      public void setSelected(boolean selected) {
40          _selected = selected;
41      }
42  
43      public void setValue(Object value) {
44          _value = String.valueOf(value);
45      }
46  
47      protected void cleanUp() {
48          _cssClass = null;
49          _label = null;
50          _selected = false;
51          _value = null;
52      }
53  
54      protected String getEndPage() {
55          return _END_PAGE;
56      }
57  
58      protected String getStartPage() {
59          return _START_PAGE;
60      }
61  
62      protected boolean isCleanUpSetAttributes() {
63          return _CLEAN_UP_SET_ATTRIBUTES;
64      }
65  
66      protected void setAttributes(HttpServletRequest request) {
67          String value = _value;
68  
69          if (Validator.isNull(value)) {
70              value = _label;
71          }
72  
73          request.setAttribute("aui:option:cssClass", _cssClass);
74          request.setAttribute(
75              "aui:option:dynamicAttributes", getDynamicAttributes());
76          request.setAttribute("aui:option:label", _label);
77          request.setAttribute(
78              "aui:option:selected", String.valueOf(_selected));
79          request.setAttribute("aui:option:value", value);
80      }
81  
82      private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
83  
84      private static final String _END_PAGE = "/html/taglib/aui/option/end.jsp";
85  
86      private static final String _START_PAGE =
87          "/html/taglib/aui/option/start.jsp";
88  
89      private String _cssClass;
90      private String _label;
91      private boolean _selected;
92      private String _value;
93  
94  }