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.PwdGenerator;
20 import com.liferay.util.TextFormatter;
21
22 import javax.servlet.http.HttpServletRequest;
23
24
31 public class InputTag extends IncludeTag {
32
33 public void setBean(Object bean) {
34 _bean = bean;
35 }
36
37 public void setChangesContext(boolean changesContext) {
38 _changesContext = changesContext;
39 }
40
41 public void setChecked(boolean checked) {
42 _checked = checked;
43 }
44
45 public void setCssClass(String cssClass) {
46 _cssClass = cssClass;
47 }
48
49 public void setDisabled(boolean disabled) {
50 _disabled = disabled;
51 }
52
53 public void setField(String field) {
54 _field = field;
55 }
56
57 public void setFirst(boolean first) {
58 _first = first;
59 }
60
61 public void setHelpMessage(String helpMessage) {
62 _helpMessage = helpMessage;
63 }
64
65 public void setId(String id) {
66 _id = id;
67 }
68
69 public void setInlineField(boolean inlineField) {
70 _inlineField = inlineField;
71 }
72
73 public void setInlineLabel(String inlineLabel) {
74 _inlineLabel = inlineLabel;
75 }
76
77 public void setLabel(String label) {
78 _label = label;
79 }
80
81 public void setLast(boolean last) {
82 _last = last;
83 }
84
85 public void setModel(Class<?> model) {
86 _model = model;
87 }
88
89 public void setName(String name) {
90 _name = name;
91 }
92
93 public void setPrefix(String prefix) {
94 _prefix = prefix;
95 }
96
97 public void setSuffix(String suffix) {
98 _suffix = suffix;
99 }
100
101 public void setTitle(String title) {
102 _title = title;
103 }
104
105 public void setType(String type) {
106 _type = type;
107 }
108
109 public void setValue(Object value) {
110 _value = value;
111 }
112
113 protected void cleanUp() {
114 _bean = null;
115 _changesContext = false;
116 _checked = false;
117 _cssClass = null;
118 _disabled = false;
119 _field = null;
120 _first = false;
121 _helpMessage = null;
122 _id = null;
123 _inlineField = false;
124 _inlineLabel = null;
125 _label = null;
126 _last = false;
127 _model = null;
128 _name = null;
129 _prefix = null;
130 _suffix = null;
131 _title = null;
132 _type = null;
133 _value = null;
134 }
135
136 protected String getPage() {
137 return _PAGE;
138 }
139
140 protected boolean isCleanUpSetAttributes() {
141 return _CLEAN_UP_SET_ATTRIBUTES;
142 }
143
144 protected void setAttributes(HttpServletRequest request) {
145 Object bean = _bean;
146
147 if (bean == null) {
148 bean = pageContext.getAttribute("aui:model-context:bean");
149 }
150
151 String field = _field;
152
153 if (Validator.isNull(field)) {
154 field = _name;
155 }
156
157 String id = _id;
158
159 if (Validator.isNull(id)) {
160 if (!Validator.equals(_type, "radio")) {
161 id = _name;
162 }
163 else {
164 id = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
165 }
166 }
167
168 String label = _label;
169
170 if (label == null) {
171 label = TextFormatter.format(_name, TextFormatter.K);
172 }
173
174 Class<?> model = _model;
175
176 if (model == null) {
177 model = (Class<?>)pageContext.getAttribute(
178 "aui:model-context:model");
179 }
180
181 request.setAttribute("aui:input:bean", bean);
182 request.setAttribute(
183 "aui:input:changesContext", String.valueOf(_changesContext));
184 request.setAttribute("aui:input:checked", String.valueOf(_checked));
185 request.setAttribute("aui:input:cssClass", _cssClass);
186 request.setAttribute("aui:input:disabled", String.valueOf(_disabled));
187 request.setAttribute(
188 "aui:input:dynamicAttributes", getDynamicAttributes());
189 request.setAttribute("aui:input:field", field);
190 request.setAttribute("aui:input:first", String.valueOf(_first));
191 request.setAttribute("aui:input:helpMessage", _helpMessage);
192 request.setAttribute("aui:input:id", id);
193 request.setAttribute(
194 "aui:input:inlineField", String.valueOf(_inlineField));
195 request.setAttribute("aui:input:inlineLabel", _inlineLabel);
196 request.setAttribute("aui:input:label", label);
197 request.setAttribute("aui:input:last", String.valueOf(_last));
198 request.setAttribute("aui:input:model", model);
199 request.setAttribute("aui:input:name", _name);
200 request.setAttribute("aui:input:prefix", _prefix);
201 request.setAttribute("aui:input:suffix", _suffix);
202 request.setAttribute("aui:input:title", _title);
203 request.setAttribute("aui:input:type", _type);
204 request.setAttribute("aui:input:value", _value);
205 }
206
207 private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
208
209 private static final String _PAGE = "/html/taglib/aui/input/page.jsp";
210
211 private Object _bean;
212 private boolean _changesContext;
213 private boolean _checked;
214 private String _cssClass;
215 private boolean _disabled;
216 private String _field;
217 private boolean _first;
218 private String _helpMessage;
219 private String _id;
220 private boolean _inlineField;
221 private String _inlineLabel;
222 private String _label;
223 private boolean _last;
224 private Class<?> _model;
225 private String _name;
226 private String _prefix;
227 private String _suffix;
228 private String _title;
229 private String _type;
230 private Object _value;
231
232 }