001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.faces.taglib.html;
018:
019: import org.apache.cocoon.faces.FacesUtils;
020: import org.apache.cocoon.faces.taglib.UIComponentTag;
021: import org.apache.commons.lang.BooleanUtils;
022:
023: import javax.faces.FacesException;
024: import javax.faces.component.UIComponent;
025: import javax.faces.component.UISelectMany;
026: import javax.faces.context.FacesContext;
027: import javax.faces.el.MethodBinding;
028: import javax.faces.event.ValueChangeEvent;
029:
030: /**
031: * @version CVS $Id: SelectManyMenuTag.java 433543 2006-08-22 06:22:54Z crossley $
032: */
033: public class SelectManyMenuTag extends UIComponentTag {
034:
035: private String converter;
036: private String immediate;
037: private String required;
038: private String validator;
039: private String value;
040: private String valueChangeListener;
041: private String accesskey;
042: private String dir;
043: private String disabled;
044: private String disabledClass;
045: private String enabledClass;
046: private String lang;
047: private String onblur;
048: private String onchange;
049: private String onclick;
050: private String ondblclick;
051: private String onfocus;
052: private String onkeydown;
053: private String onkeypress;
054: private String onkeyup;
055: private String onmousedown;
056: private String onmousemove;
057: private String onmouseout;
058: private String onmouseover;
059: private String onmouseup;
060: private String onselect;
061: private String readonly;
062: private String style;
063: private String styleClass;
064: private String tabindex;
065: private String title;
066:
067: public void setConverter(String converter) {
068: this .converter = converter;
069: }
070:
071: public void setImmediate(String immediate) {
072: this .immediate = immediate;
073: }
074:
075: public void setRequired(String required) {
076: this .required = required;
077: }
078:
079: public void setValidator(String validator) {
080: this .validator = validator;
081: }
082:
083: public void setValue(String value) {
084: this .value = value;
085: }
086:
087: public void setValueChangeListener(String valueChangeListener) {
088: this .valueChangeListener = valueChangeListener;
089: }
090:
091: public void setAccesskey(String accesskey) {
092: this .accesskey = accesskey;
093: }
094:
095: public void setDir(String dir) {
096: this .dir = dir;
097: }
098:
099: public void setDisabled(String disabled) {
100: this .disabled = disabled;
101: }
102:
103: public void setDisabledClass(String disabledClass) {
104: this .disabledClass = disabledClass;
105: }
106:
107: public void setEnabledClass(String enabledClass) {
108: this .enabledClass = enabledClass;
109: }
110:
111: public void setLang(String lang) {
112: this .lang = lang;
113: }
114:
115: public void setOnblur(String onblur) {
116: this .onblur = onblur;
117: }
118:
119: public void setOnchange(String onchange) {
120: this .onchange = onchange;
121: }
122:
123: public void setOnclick(String onclick) {
124: this .onclick = onclick;
125: }
126:
127: public void setOndblclick(String ondblclick) {
128: this .ondblclick = ondblclick;
129: }
130:
131: public void setOnfocus(String onfocus) {
132: this .onfocus = onfocus;
133: }
134:
135: public void setOnkeydown(String onkeydown) {
136: this .onkeydown = onkeydown;
137: }
138:
139: public void setOnkeypress(String onkeypress) {
140: this .onkeypress = onkeypress;
141: }
142:
143: public void setOnkeyup(String onkeyup) {
144: this .onkeyup = onkeyup;
145: }
146:
147: public void setOnmousedown(String onmousedown) {
148: this .onmousedown = onmousedown;
149: }
150:
151: public void setOnmousemove(String onmousemove) {
152: this .onmousemove = onmousemove;
153: }
154:
155: public void setOnmouseout(String onmouseout) {
156: this .onmouseout = onmouseout;
157: }
158:
159: public void setOnmouseover(String onmouseover) {
160: this .onmouseover = onmouseover;
161: }
162:
163: public void setOnmouseup(String onmouseup) {
164: this .onmouseup = onmouseup;
165: }
166:
167: public void setOnselect(String onselect) {
168: this .onselect = onselect;
169: }
170:
171: public void setReadonly(String readonly) {
172: this .readonly = readonly;
173: }
174:
175: public void setStyle(String style) {
176: this .style = style;
177: }
178:
179: public void setStyleClass(String styleClass) {
180: this .styleClass = styleClass;
181: }
182:
183: public void setTabindex(String tabindex) {
184: this .tabindex = tabindex;
185: }
186:
187: public void setTitle(String title) {
188: this .title = title;
189: }
190:
191: public String getRendererType() {
192: return "javax.faces.Menu";
193: }
194:
195: public String getComponentType() {
196: return "javax.faces.HtmlSelectManyMenu";
197: }
198:
199: protected void setProperties(UIComponent component) {
200: super .setProperties(component);
201:
202: UISelectMany select;
203: try {
204: select = (UISelectMany) component;
205: } catch (ClassCastException cce) {
206: throw new FacesException("Tag <" + getClass().getName()
207: + "> expected UISelectMany. " + "Got <"
208: + component.getClass().getName() + ">");
209: }
210:
211: if (converter != null) {
212: if (FacesUtils.isExpression(converter)) {
213: select.setValueBinding("converter",
214: createValueBinding(converter));
215: } else {
216: select.setConverter(getApplication().createConverter(
217: converter));
218: }
219: }
220:
221: if (immediate != null) {
222: if (FacesUtils.isExpression(immediate)) {
223: select.setValueBinding("immediate",
224: createValueBinding(immediate));
225: } else {
226: select.setImmediate(BooleanUtils.toBoolean(immediate));
227: }
228: }
229:
230: if (required != null) {
231: if (FacesUtils.isExpression(required)) {
232: select.setValueBinding("required",
233: createValueBinding(required));
234: } else {
235: select.setRequired(BooleanUtils.toBoolean(required));
236: }
237: }
238:
239: if (validator != null) {
240: if (FacesUtils.isExpression(validator)) {
241: MethodBinding vb = getApplication()
242: .createMethodBinding(
243: validator,
244: new Class[] { FacesContext.class,
245: UIComponent.class, Object.class });
246: select.setValidator(vb);
247: } else {
248: throw new FacesException("Tag <" + getClass().getName()
249: + "> validator must be an expression. "
250: + "Got <" + validator + ">");
251: }
252: }
253:
254: if (value != null) {
255: if (FacesUtils.isExpression(value)) {
256: select.setValueBinding("value",
257: createValueBinding(value));
258: } else {
259: select.setValue(value);
260: }
261: }
262:
263: if (valueChangeListener != null) {
264: if (FacesUtils.isExpression(valueChangeListener)) {
265: MethodBinding vb = getApplication()
266: .createMethodBinding(valueChangeListener,
267: new Class[] { ValueChangeEvent.class });
268: select.setValueChangeListener(vb);
269: } else {
270: throw new FacesException(
271: "Tag <"
272: + getClass().getName()
273: + "> valueChangeListener must be an expression. "
274: + "Got <" + valueChangeListener + ">");
275: }
276: }
277:
278: setProperty(component, "accesskey", accesskey);
279:
280: setProperty(component, "dir", dir);
281:
282: setBooleanProperty(component, "disabled", disabled);
283:
284: setProperty(component, "disabledClass", disabledClass);
285: setProperty(component, "enabledClass", enabledClass);
286: setProperty(component, "lang", lang);
287: setProperty(component, "onblur", onblur);
288: setProperty(component, "onchange", onchange);
289: setProperty(component, "onclick", onclick);
290: setProperty(component, "ondblclick", ondblclick);
291: setProperty(component, "onfocus", onfocus);
292: setProperty(component, "onkeydown", onkeydown);
293: setProperty(component, "onkeypress", onkeypress);
294: setProperty(component, "onkeyup", onkeyup);
295: setProperty(component, "onmousedown", onmousedown);
296: setProperty(component, "onmousemove", onmousemove);
297: setProperty(component, "onmouseout", onmouseout);
298: setProperty(component, "onmouseover", onmouseover);
299: setProperty(component, "onmouseup", onmouseup);
300: setProperty(component, "onselect", onselect);
301:
302: setBooleanProperty(component, "readonly", readonly);
303:
304: setProperty(component, "style", style);
305: setProperty(component, "styleClass", styleClass);
306: setProperty(component, "tabindex", tabindex);
307: setProperty(component, "title", title);
308: }
309:
310: public void recycle() {
311: super.recycle();
312: converter = null;
313: immediate = null;
314: required = null;
315: validator = null;
316: value = null;
317: valueChangeListener = null;
318: accesskey = null;
319: dir = null;
320: disabled = null;
321: disabledClass = null;
322: enabledClass = null;
323: lang = null;
324: onblur = null;
325: onchange = null;
326: onclick = null;
327: ondblclick = null;
328: onfocus = null;
329: onkeydown = null;
330: onkeypress = null;
331: onkeyup = null;
332: onmousedown = null;
333: onmousemove = null;
334: onmouseout = null;
335: onmouseover = null;
336: onmouseup = null;
337: onselect = null;
338: readonly = null;
339: style = null;
340: styleClass = null;
341: tabindex = null;
342: title = null;
343: }
344: }
|