01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.faces.taglib;
18:
19: import org.apache.cocoon.faces.FacesUtils;
20:
21: import javax.faces.FacesException;
22: import javax.faces.component.UIComponent;
23: import javax.faces.component.UISelectItems;
24:
25: /**
26: * @version CVS $Id: SelectItemsTag.java 433543 2006-08-22 06:22:54Z crossley $
27: */
28: public class SelectItemsTag extends UIComponentTag {
29:
30: protected String value;
31:
32: public void setValue(String value) {
33: this .value = value;
34: }
35:
36: protected String getComponentType() {
37: return "javax.faces.SelectItems";
38: }
39:
40: protected String getRendererType() {
41: return null;
42: }
43:
44: protected void setProperties(UIComponent component) {
45: super .setProperties(component);
46:
47: UISelectItems selectItems;
48: try {
49: selectItems = (UISelectItems) component;
50: } catch (ClassCastException cce) {
51: throw new FacesException("Tag <" + getClass().getName()
52: + "> expected UISelectItems. " + "Got <"
53: + component.getClass().getName() + ">");
54: }
55:
56: if (value != null) {
57: if (FacesUtils.isExpression(value)) {
58: selectItems.setValueBinding("value",
59: createValueBinding(value));
60: } else {
61: selectItems.setValue(value);
62: }
63: }
64: }
65:
66: public void recycle() {
67: super.recycle();
68: this.value = null;
69: }
70: }
|