01: // WARNING: This file was automatically generated. Do not edit it directly,
02: // or you will lose your changes.
03:
04: /*
05: * Licensed to the Apache Software Foundation (ASF) under one
06: * or more contributor license agreements. See the NOTICE file
07: * distributed with this work for additional information
08: * regarding copyright ownership. The ASF licenses this file
09: * to you under the Apache License, Version 2.0 (the
10: * "License"); you may not use this file except in compliance
11: * with the License. You may obtain a copy of the License at
12: *
13: * http://www.apache.org/licenses/LICENSE-2.0
14: *
15: * Unless required by applicable law or agreed to in writing,
16: * software distributed under the License is distributed on an
17: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18: * KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations
20: * under the License.
21: */
22: package javax.faces.component;
23:
24: import javax.el.ValueExpression;
25: import javax.faces.context.FacesContext;
26:
27: /**
28: *
29: * <h4>Events:</h4>
30: * <table border="1" width="100%" cellpadding="3" summary="">
31: * <tr bgcolor="#CCCCFF" class="TableHeadingColor">
32: * <th align="left">Type</th>
33: * <th align="left">Phases</th>
34: * <th align="left">Description</th>
35: * </tr>
36: * <tr class="TableRowColor">
37: * <td valign="top"><code>javax.faces.event.ValueChangeEvent</code></td>
38: * <td valign="top" nowrap></td>
39: * <td valign="top">The valueChange event is delivered when the value
40: attribute is changed.</td>
41: * </tr>
42: * </table>
43: */
44: public class UISelectOne extends UIInput {
45:
46: static public final String COMPONENT_FAMILY = "javax.faces.SelectOne";
47: static public final String COMPONENT_TYPE = "javax.faces.SelectOne";
48:
49: /**
50: * Construct an instance of the UISelectOne.
51: */
52: public UISelectOne() {
53: setRendererType("javax.faces.Menu");
54: }
55:
56: public static final String INVALID_MESSAGE_ID = "javax.faces.component.UISelectOne.INVALID";
57:
58: /**
59: * Verify that the result of converting the newly submitted value is
60: * <i>equal</i> to the value property of one of the child SelectItem
61: * objects. If this is not true, a validation error is reported.
62: *
63: * @see javax.faces.component.UIInput#validateValue(javax.faces.context.FacesContext,java.lang.Object)
64: */
65: protected void validateValue(FacesContext context, Object value) {
66: super .validateValue(context, value);
67:
68: if (!isValid() || value == null) {
69: return;
70: }
71:
72: _SelectItemsUtil._ValueConverter converter = new _SelectItemsUtil._ValueConverter() {
73: public Object getConvertedValue(FacesContext context,
74: String value) {
75: return UISelectOne.this .getConvertedValue(context,
76: value);
77: }
78: };
79:
80: // selected value must match to one of the available options
81: if (!_SelectItemsUtil.matchValue(context, value,
82: new _SelectItemsIterator(this ), converter)) {
83: _MessageUtils.addErrorMessage(context, this ,
84: INVALID_MESSAGE_ID, new Object[] { _MessageUtils
85: .getLabel(context, this ) });
86: setValid(false);
87: }
88: }
89:
90: @Override
91: public String getFamily() {
92: return COMPONENT_FAMILY;
93: }
94: }
|