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 setLabel(String label) {
090 _label = label;
091 }
092
093 public void setLast(boolean last) {
094 _last = last;
095 }
096
097 public void setModel(Class<?> model) {
098 _model = model;
099 }
100
101 public void setName(String name) {
102 _name = name;
103 }
104
105 public void setOnClick(String onClick) {
106 _onClick = onClick;
107 }
108
109 public void setPrefix(String prefix) {
110 _prefix = prefix;
111 }
112
113 public void setSuffix(String suffix) {
114 _suffix = suffix;
115 }
116
117 public void setTitle(String title) {
118 _title = title;
119 }
120
121 public void setType(String type) {
122 _type = type;
123 }
124
125 public void setValue(Object value) {
126 _value = value;
127 }
128
129 protected void cleanUp() {
130 _bean = null;
131 _changesContext = false;
132 _checked = false;
133 _classPK = 0;
134 _cssClass = null;
135 _data = null;
136 _disabled = false;
137 _field = null;
138 _fieldParam = null;
139 _first = false;
140 _helpMessage = null;
141 _id = null;
142 _inlineField = false;
143 _inlineLabel = null;
144 _label = null;
145 _last = false;
146 _model = null;
147 _name = null;
148 _onClick = null;
149 _prefix = null;
150 _suffix = null;
151 _title = null;
152 _type = null;
153 _value = null;
154 }
155
156 protected String getPage() {
157 return _PAGE;
158 }
159
160 protected boolean isCleanUpSetAttributes() {
161 return _CLEAN_UP_SET_ATTRIBUTES;
162 }
163
164 protected void setAttributes(HttpServletRequest request) {
165 Object bean = _bean;
166
167 if (bean == null) {
168 bean = pageContext.getAttribute("aui:model-context:bean");
169 }
170
171 String field = _field;
172
173 if (Validator.isNull(field)) {
174 field = _name;
175 }
176
177 String id = _id;
178
179 if (Validator.isNull(id)) {
180 if (!Validator.equals(_type, "radio")) {
181 id = _name;
182 }
183 else {
184 id = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
185 }
186 }
187
188 String label = _label;
189
190 if (label == null) {
191 label = TextFormatter.format(_name, TextFormatter.K);
192 }
193
194 Class<?> model = _model;
195
196 if (model == null) {
197 model = (Class<?>)pageContext.getAttribute(
198 "aui:model-context:model");
199 }
200
201 request.setAttribute("aui:input:bean", bean);
202 request.setAttribute(
203 "aui:input:changesContext", String.valueOf(_changesContext));
204 request.setAttribute("aui:input:checked", String.valueOf(_checked));
205 request.setAttribute("aui:input:classPK", String.valueOf(_classPK));
206 request.setAttribute("aui:input:cssClass", _cssClass);
207 request.setAttribute("aui:input:data", _data);
208 request.setAttribute("aui:input:disabled", String.valueOf(_disabled));
209 request.setAttribute(
210 "aui:input:dynamicAttributes", getDynamicAttributes());
211 request.setAttribute("aui:input:field", field);
212 request.setAttribute("aui:input:fieldParam", _fieldParam);
213 request.setAttribute("aui:input:first", String.valueOf(_first));
214 request.setAttribute("aui:input:helpMessage", _helpMessage);
215 request.setAttribute("aui:input:id", id);
216 request.setAttribute(
217 "aui:input:inlineField", String.valueOf(_inlineField));
218 request.setAttribute("aui:input:inlineLabel", _inlineLabel);
219 request.setAttribute("aui:input:label", label);
220 request.setAttribute("aui:input:last", String.valueOf(_last));
221 request.setAttribute("aui:input:model", model);
222 request.setAttribute("aui:input:name", _name);
223 request.setAttribute("aui:input:onClick", _onClick);
224 request.setAttribute("aui:input:prefix", _prefix);
225 request.setAttribute("aui:input:suffix", _suffix);
226 request.setAttribute("aui:input:title", _title);
227 request.setAttribute("aui:input:type", _type);
228 request.setAttribute("aui:input:value", _value);
229 }
230
231 private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
232
233 private static final String _PAGE = "/html/taglib/aui/input/page.jsp";
234
235 private Object _bean;
236 private boolean _changesContext;
237 private boolean _checked;
238 private long _classPK;
239 private String _cssClass;
240 private Map<String, Object> _data;
241 private boolean _disabled;
242 private String _field;
243 private String _fieldParam;
244 private boolean _first;
245 private String _helpMessage;
246 private String _id;
247 private boolean _inlineField;
248 private String _inlineLabel;
249 private String _label;
250 private boolean _last;
251 private Class<?> _model;
252 private String _name;
253 private String _onClick;
254 private String _prefix;
255 private String _suffix;
256 private String _title;
257 private String _type;
258 private Object _value;
259
260 }