1
14
15 package com.liferay.taglib.aui;
16
17 import com.liferay.portal.kernel.util.Validator;
18 import com.liferay.taglib.util.IncludeTag;
19 import com.liferay.util.TextFormatter;
20
21 import javax.servlet.http.HttpServletRequest;
22
23
30 public class SelectTag extends IncludeTag {
31
32 public void setBean(Object bean) {
33 _bean = bean;
34 }
35
36 public void setChangesContext(boolean changesContext) {
37 _changesContext = changesContext;
38 }
39
40 public void setCssClass(String cssClass) {
41 _cssClass = cssClass;
42 }
43
44 public void setDisabled(boolean disabled) {
45 _disabled = disabled;
46 }
47
48 public void setFirst(boolean first) {
49 _first = first;
50 }
51
52 public void setHelpMessage(String helpMessage) {
53 _helpMessage = helpMessage;
54 }
55
56 public void setId(String id) {
57 _id = id;
58 }
59
60 public void setInlineField(boolean inlineField) {
61 _inlineField = inlineField;
62 }
63
64 public void setInlineLabel(String inlineLabel) {
65 _inlineLabel = inlineLabel;
66 }
67
68 public void setLabel(String label) {
69 _label = label;
70 }
71
72 public void setLast(boolean last) {
73 _last = last;
74 }
75
76 public void setListType(String listType) {
77 _listType = listType;
78 }
79
80 public void setListTypeFieldName(String listTypeFieldName) {
81 _listTypeFieldName = listTypeFieldName;
82 }
83
84 public void setMultiple(boolean multiple) {
85 _multiple = multiple;
86 }
87
88 public void setName(String name) {
89 _name = name;
90 }
91
92 public void setPrefix(String prefix) {
93 _prefix = prefix;
94 }
95
96 public void setShowEmptyOption(boolean showEmptyOption) {
97 _showEmptyOption = showEmptyOption;
98 }
99
100 public void setTitle(String title) {
101 _title = title;
102 }
103
104 public void setSuffix(String suffix) {
105 _suffix = suffix;
106 }
107
108 protected void cleanUp() {
109 _bean = null;
110 _changesContext = false;
111 _cssClass = null;
112 _first = false;
113 _helpMessage = null;
114 _inlineField = false;
115 _inlineLabel = null;
116 _id = null;
117 _label = null;
118 _last = false;
119 _listType = null;
120 _listTypeFieldName = null;
121 _multiple = false;
122 _name = null;
123 _prefix = null;
124 _showEmptyOption = false;
125 _suffix = null;
126 _title = null;
127 }
128
129 protected String getEndPage() {
130 return _END_PAGE;
131 }
132
133 protected String getStartPage() {
134 return _START_PAGE;
135 }
136
137 protected boolean isCleanUpSetAttributes() {
138 return _CLEAN_UP_SET_ATTRIBUTES;
139 }
140
141 protected void setAttributes(HttpServletRequest request) {
142 Object bean = _bean;
143
144 if (bean == null) {
145 bean = pageContext.getAttribute("aui:model-context:bean");
146 }
147
148 String id = _id;
149
150 if (Validator.isNull(id)) {
151 id = _name;
152 }
153
154 String label = _label;
155
156 if (label == null) {
157 label = TextFormatter.format(_name, TextFormatter.K);
158 }
159
160 String listTypeFieldName = _listTypeFieldName;
161
162 if (Validator.isNotNull(_listType) &&
163 Validator.isNull(listTypeFieldName)) {
164
165 listTypeFieldName = "typeId";
166 }
167
168 request.setAttribute("aui:select:bean", bean);
169 request.setAttribute(
170 "aui:select:changesContext", String.valueOf(_changesContext));
171 request.setAttribute("aui:select:cssClass", _cssClass);
172 request.setAttribute("aui:select:disabled", String.valueOf(_disabled));
173 request.setAttribute(
174 "aui:select:dynamicAttributes", getDynamicAttributes());
175 request.setAttribute("aui:select:first", String.valueOf(_first));
176 request.setAttribute("aui:select:helpMessage", _helpMessage);
177 request.setAttribute(
178 "aui:select:inlineField", String.valueOf(_inlineField));
179 request.setAttribute("aui:select:inlineLabel", _inlineLabel);
180 request.setAttribute("aui:select:id", id);
181 request.setAttribute("aui:select:label", label);
182 request.setAttribute("aui:select:last", String.valueOf(_last));
183 request.setAttribute("aui:select:listType", _listType);
184 request.setAttribute("aui:select:listTypeFieldName", listTypeFieldName);
185 request.setAttribute("aui:select:multiple", String.valueOf(_multiple));
186 request.setAttribute("aui:select:name", _name);
187 request.setAttribute("aui:select:prefix", _prefix);
188 request.setAttribute(
189 "aui:select:showEmptyOption", String.valueOf(_showEmptyOption));
190 request.setAttribute("aui:select:suffix", _suffix);
191 request.setAttribute("aui:select:title", _title);
192 }
193
194 private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
195
196 private static final String _END_PAGE = "/html/taglib/aui/select/end.jsp";
197
198 private static final String _START_PAGE =
199 "/html/taglib/aui/select/start.jsp";
200
201 private Object _bean;
202 private boolean _changesContext;
203 private String _cssClass;
204 private boolean _disabled;
205 private boolean _first;
206 private String _helpMessage;
207 private String _id;
208 private boolean _inlineField;
209 private String _inlineLabel;
210 private String _label;
211 private boolean _last;
212 private String _listType;
213 private String _listTypeFieldName;
214 private boolean _multiple;
215 private String _name;
216 private String _prefix;
217 private boolean _showEmptyOption;
218 private String _suffix;
219 private String _title;
220
221 }