001
014
015 package com.liferay.taglib.aui;
016
017 import com.liferay.portal.kernel.util.Validator;
018 import com.liferay.taglib.util.IncludeTag;
019 import com.liferay.util.PwdGenerator;
020 import com.liferay.util.TextFormatter;
021
022 import java.util.Map;
023
024 import javax.servlet.http.HttpServletRequest;
025
026
031 public class InputTag extends IncludeTag {
032
033 public void setBean(Object bean) {
034 _bean = bean;
035 }
036
037 public void setChangesContext(boolean changesContext) {
038 _changesContext = changesContext;
039 }
040
041 public void setChecked(boolean checked) {
042 _checked = checked;
043 }
044
045 public void setClassPK(long classPK) {
046 _classPK = classPK;
047 }
048
049 public void setCssClass(String cssClass) {
050 _cssClass = cssClass;
051 }
052
053 public void setData(Map<String,Object> data) {
054 _data = data;
055 }
056
057 public void setDisabled(boolean disabled) {
058 _disabled = disabled;
059 }
060
061 public void setField(String field) {
062 _field = field;
063 }
064
065 public void setFieldParam(String fieldParam) {
066 _fieldParam = fieldParam;
067 }
068
069 public void setFirst(boolean first) {
070 _first = first;
071 }
072
073 public void setHelpMessage(String helpMessage) {
074 _helpMessage = helpMessage;
075 }
076
077 public void setId(String id) {
078 _id = id;
079 }
080
081 public void setInlineField(boolean inlineField) {
082 _inlineField = inlineField;
083 }
084
085 public void setInlineLabel(String inlineLabel) {
086 _inlineLabel = inlineLabel;
087 }
088
089 public void setInputCssClass(String inputCssClass) {
090 _inputCssClass = inputCssClass;
091 }
092
093 public void setLabel(String label) {
094 _label = label;
095 }
096
097 public void setLast(boolean last) {
098 _last = last;
099 }
100
101 public void setModel(Class<?> model) {
102 _model = model;
103 }
104
105 public void setName(String name) {
106 _name = name;
107 }
108
109 public void setOnChange(String onChange) {
110 _onChange = onChange;
111 }
112
113 public void setOnClick(String onClick) {
114 _onClick = onClick;
115 }
116
117 public void setPrefix(String prefix) {
118 _prefix = prefix;
119 }
120
121 public void setSuffix(String suffix) {
122 _suffix = suffix;
123 }
124
125 public void setTitle(String title) {
126 _title = title;
127 }
128
129 public void setType(String type) {
130 _type = type;
131 }
132
133 public void setValue(Object value) {
134 _value = value;
135 }
136
137 protected void cleanUp() {
138 _bean = null;
139 _changesContext = false;
140 _checked = false;
141 _classPK = 0;
142 _cssClass = null;
143 _data = null;
144 _disabled = false;
145 _field = null;
146 _fieldParam = null;
147 _first = false;
148 _helpMessage = null;
149 _id = null;
150 _inlineField = false;
151 _inlineLabel = null;
152 _inputCssClass = null;
153 _label = null;
154 _last = false;
155 _model = null;
156 _name = null;
157 _onChange = null;
158 _onClick = null;
159 _prefix = null;
160 _suffix = null;
161 _title = null;
162 _type = null;
163 _value = null;
164 }
165
166 protected String getPage() {
167 return _PAGE;
168 }
169
170 protected boolean isCleanUpSetAttributes() {
171 return _CLEAN_UP_SET_ATTRIBUTES;
172 }
173
174 protected void setAttributes(HttpServletRequest request) {
175 Object bean = _bean;
176
177 if (bean == null) {
178 bean = pageContext.getAttribute("aui:model-context:bean");
179 }
180
181 String field = _field;
182
183 if (Validator.isNull(field)) {
184 field = _name;
185 }
186
187 String id = _id;
188
189 if (Validator.isNull(id)) {
190 if (!Validator.equals(_type, "radio")) {
191 id = _name;
192 }
193 else {
194 id = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
195 }
196 }
197
198 String label = _label;
199
200 if (label == null) {
201 label = TextFormatter.format(_name, TextFormatter.K);
202 }
203
204 Class<?> model = _model;
205
206 if (model == null) {
207 model = (Class<?>)pageContext.getAttribute(
208 "aui:model-context:model");
209 }
210
211 request.setAttribute("aui:input:bean", bean);
212 request.setAttribute(
213 "aui:input:changesContext", String.valueOf(_changesContext));
214 request.setAttribute("aui:input:checked", String.valueOf(_checked));
215 request.setAttribute("aui:input:classPK", String.valueOf(_classPK));
216 request.setAttribute("aui:input:cssClass", _cssClass);
217 request.setAttribute("aui:input:data", _data);
218 request.setAttribute("aui:input:disabled", String.valueOf(_disabled));
219 request.setAttribute(
220 "aui:input:dynamicAttributes", getDynamicAttributes());
221 request.setAttribute("aui:input:field", field);
222 request.setAttribute("aui:input:fieldParam", _fieldParam);
223 request.setAttribute("aui:input:first", String.valueOf(_first));
224 request.setAttribute("aui:input:helpMessage", _helpMessage);
225 request.setAttribute("aui:input:id", id);
226 request.setAttribute(
227 "aui:input:inlineField", String.valueOf(_inlineField));
228 request.setAttribute("aui:input:inlineLabel", _inlineLabel);
229 request.setAttribute("aui:input:inputCssClass", _inputCssClass);
230 request.setAttribute("aui:input:label", label);
231 request.setAttribute("aui:input:last", String.valueOf(_last));
232 request.setAttribute("aui:input:model", model);
233 request.setAttribute("aui:input:name", _name);
234 request.setAttribute("aui:input:onChange", _onChange);
235 request.setAttribute("aui:input:onClick", _onClick);
236 request.setAttribute("aui:input:prefix", _prefix);
237 request.setAttribute("aui:input:suffix", _suffix);
238 request.setAttribute("aui:input:title", _title);
239 request.setAttribute("aui:input:type", _type);
240 request.setAttribute("aui:input:value", _value);
241 }
242
243 private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
244
245 private static final String _PAGE = "/html/taglib/aui/input/page.jsp";
246
247 private Object _bean;
248 private boolean _changesContext;
249 private boolean _checked;
250 private long _classPK;
251 private String _cssClass;
252 private Map<String, Object> _data;
253 private boolean _disabled;
254 private String _field;
255 private String _fieldParam;
256 private boolean _first;
257 private String _helpMessage;
258 private String _id;
259 private boolean _inlineField;
260 private String _inlineLabel;
261 private String _inputCssClass;
262 private String _label;
263 private boolean _last;
264 private Class<?> _model;
265 private String _name;
266 private String _onChange;
267 private String _onClick;
268 private String _prefix;
269 private String _suffix;
270 private String _title;
271 private String _type;
272 private Object _value;
273
274 }