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.taglib.util.IncludeTag;
18  import com.liferay.util.TextFormatter;
19  
20  import javax.servlet.http.HttpServletRequest;
21  
22  /**
23   * <a href="FieldWrapperTag.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 FieldWrapperTag extends IncludeTag {
30  
31      public void setCssClass(String cssClass) {
32          _cssClass = cssClass;
33      }
34  
35      public void setFirst(boolean first) {
36          _first = first;
37      }
38  
39      public void setHelpMessage(String helpMessage) {
40          _helpMessage = helpMessage;
41      }
42  
43      public void setInlineField(boolean inlineField) {
44          _inlineField = inlineField;
45      }
46  
47      public void setInlineLabel(String inlineLabel) {
48          _inlineLabel = inlineLabel;
49      }
50  
51      public void setLabel(String label) {
52          _label = label;
53      }
54  
55      public void setLast(boolean last) {
56          _last = last;
57      }
58  
59      public void setName(String name) {
60          _name = name;
61      }
62  
63      protected void cleanUp() {
64          _cssClass = null;
65          _first = false;
66          _helpMessage = null;
67          _inlineField = false;
68          _inlineLabel = null;
69          _label = null;
70          _last = false;
71          _name = null;
72      }
73  
74      protected String getEndPage() {
75          return _END_PAGE;
76      }
77  
78      protected String getStartPage() {
79          return _START_PAGE;
80      }
81  
82      protected boolean isCleanUpSetAttributes() {
83          return _CLEAN_UP_SET_ATTRIBUTES;
84      }
85  
86      protected void setAttributes(HttpServletRequest request) {
87          String label = _label;
88  
89          if (label == null) {
90              label = TextFormatter.format(_name, TextFormatter.K);
91          }
92  
93          request.setAttribute("aui:field-wrapper:cssClass", _cssClass);
94          request.setAttribute(
95              "aui:field-wrapper:dynamicAttributes", getDynamicAttributes());
96          request.setAttribute("aui:field-wrapper:first", String.valueOf(_first));
97          request.setAttribute("aui:field-wrapper:helpMessage", _helpMessage);
98          request.setAttribute(
99              "aui:field-wrapper:inlineField", String.valueOf(_inlineField));
100         request.setAttribute("aui:field-wrapper:inlineLabel", _inlineLabel);
101         request.setAttribute("aui:field-wrapper:label", label);
102         request.setAttribute("aui:field-wrapper:last", String.valueOf(_last));
103         request.setAttribute("aui:field-wrapper:name", _name);
104     }
105 
106     private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
107 
108     private static final String _END_PAGE =
109         "/html/taglib/aui/field_wrapper/end.jsp";
110 
111     private static final String _START_PAGE =
112         "/html/taglib/aui/field_wrapper/start.jsp";
113 
114     private String _cssClass;
115     private boolean _first;
116     private String _helpMessage;
117     private boolean _inlineField;
118     private String _inlineLabel;
119     private String _label;
120     private boolean _last;
121     private String _name;
122 
123 }