001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package com.sun.rave.web.ui.component;
042:
043: import java.io.IOException;
044: import javax.faces.component.UIComponent;
045: import javax.faces.context.FacesContext;
046: import javax.faces.el.MethodBinding;
047: import javax.faces.el.ValueBinding;
048:
049: /**
050: * This renderer meta-data is not mapped one to one with a component.
051: * A renderer of this name does exist as the super class of the
052: * RadioButton and Checkbox renderers.
053: * <p>Auto-generated component class.
054: * Do <strong>NOT</strong> modify; all changes
055: * <strong>will</strong> be lost!</p>
056: */
057:
058: public abstract class RbCbSelectorBase extends
059: com.sun.rave.web.ui.component.Selector {
060:
061: /**
062: * <p>Construct a new <code>RbCbSelectorBase</code>.</p>
063: */
064: public RbCbSelectorBase() {
065: super ();
066: setRendererType("com.sun.rave.web.ui.RbCbSelectorRenderer");
067: }
068:
069: /**
070: * <p>Return the identifier of the component family to which this
071: * component belongs. This identifier, in conjunction with the value
072: * of the <code>rendererType</code> property, may be used to select
073: * the appropriate {@link Renderer} for this component instance.</p>
074: */
075: public String getFamily() {
076: return "com.sun.rave.web.ui.RbCbSelector";
077: }
078:
079: /**
080: * <p>Return the <code>ValueBinding</code> stored for the
081: * specified name (if any), respecting any property aliases.</p>
082: *
083: * @param name Name of value binding to retrieve
084: */
085: public ValueBinding getValueBinding(String name) {
086: if (name.equals("selected")) {
087: return super .getValueBinding("value");
088: }
089: if (name.equals("selectedValue")) {
090: return super .getValueBinding("items");
091: }
092: return super .getValueBinding(name);
093: }
094:
095: /**
096: * <p>Set the <code>ValueBinding</code> stored for the
097: * specified name (if any), respecting any property
098: * aliases.</p>
099: *
100: * @param name Name of value binding to set
101: * @param binding ValueBinding to set, or null to remove
102: */
103: public void setValueBinding(String name, ValueBinding binding) {
104: if (name.equals("selected")) {
105: super .setValueBinding("value", binding);
106: return;
107: }
108: if (name.equals("selectedValue")) {
109: super .setValueBinding("items", binding);
110: return;
111: }
112: super .setValueBinding(name, binding);
113: }
114:
115: // imageURL
116: private String imageURL = null;
117:
118: /**
119: * <p>
120: * A context relative path of an image to be displayed with
121: * the control. If you want to be able to specify attributes
122: * for the image, specify an <code>image</code> facet instead
123: * of the <code>imageURL</code> attribute.</p>
124: */
125: public String getImageURL() {
126: if (this .imageURL != null) {
127: return this .imageURL;
128: }
129: ValueBinding _vb = getValueBinding("imageURL");
130: if (_vb != null) {
131: return (String) _vb.getValue(getFacesContext());
132: }
133: return null;
134: }
135:
136: /**
137: * <p>
138: * A context relative path of an image to be displayed with
139: * the control. If you want to be able to specify attributes
140: * for the image, specify an <code>image</code> facet instead
141: * of the <code>imageURL</code> attribute.</p>
142: * @see #getImageURL()
143: */
144: public void setImageURL(String imageURL) {
145: this .imageURL = imageURL;
146: }
147:
148: // name
149: private String name = null;
150:
151: /**
152: * <p>
153: * Identifies the control as participating as part
154: * of a group. The <code>RadioButton</code> and <code>Checkbox</code>
155: * classes determine the behavior of the group,
156: * that are assigned the same value to the <code>name</code>
157: * property. The value of this property must be unique for components
158: * in the group, within the scope of the <code>Form</code>
159: * parent component containing the grouped components.</p>
160: */
161: public String getName() {
162: if (this .name != null) {
163: return this .name;
164: }
165: ValueBinding _vb = getValueBinding("name");
166: if (_vb != null) {
167: return (String) _vb.getValue(getFacesContext());
168: }
169: return null;
170: }
171:
172: /**
173: * <p>
174: * Identifies the control as participating as part
175: * of a group. The <code>RadioButton</code> and <code>Checkbox</code>
176: * classes determine the behavior of the group,
177: * that are assigned the same value to the <code>name</code>
178: * property. The value of this property must be unique for components
179: * in the group, within the scope of the <code>Form</code>
180: * parent component containing the grouped components.</p>
181: * @see #getName()
182: */
183: public void setName(String name) {
184: this .name = name;
185: }
186:
187: // selected
188: /**
189: * <p>The object that represents the selections made from the
190: * available options. If multiple selections are allowed, this
191: * must be bound to ArrayList, an Object array, or an array of
192: * primitives.</p>
193: */
194: public Object getSelected() {
195: return getValue();
196: }
197:
198: /**
199: * <p>The object that represents the selections made from the
200: * available options. If multiple selections are allowed, this
201: * must be bound to ArrayList, an Object array, or an array of
202: * primitives.</p>
203: * @see #getSelected()
204: */
205: public void setSelected(Object selected) {
206: setValue(selected);
207: }
208:
209: // selectedValue
210: /**
211: * <p>
212: * The value of the component when it is selected. The value of this
213: * property is assigned to the <code>selected</code> property when
214: * the component is selected. The component is selected
215: * when the <code>selected</code> property is equal to this value.</br>
216: * This attribute can be bound to a <code>String</code>, or <code>
217: * Object</code> value.</br>
218: * If this property is not assigned a value, the component behaves
219: * as a boolean component. A boolean component
220: * is selected when the <code>selected</code> property is equal to a
221: * true <code>Boolean</code> instance.<br>
222: * If a boolean component is not selected, the <code>selected</code>
223: * property value is a false <code>Boolean</code> instance.</p>
224: */
225: public Object getSelectedValue() {
226: return getItems();
227: }
228:
229: /**
230: * <p>
231: * The value of the component when it is selected. The value of this
232: * property is assigned to the <code>selected</code> property when
233: * the component is selected. The component is selected
234: * when the <code>selected</code> property is equal to this value.</br>
235: * This attribute can be bound to a <code>String</code>, or <code>
236: * Object</code> value.</br>
237: * If this property is not assigned a value, the component behaves
238: * as a boolean component. A boolean component
239: * is selected when the <code>selected</code> property is equal to a
240: * true <code>Boolean</code> instance.<br>
241: * If a boolean component is not selected, the <code>selected</code>
242: * property value is a false <code>Boolean</code> instance.</p>
243: * @see #getSelectedValue()
244: */
245: public void setSelectedValue(Object selectedValue) {
246: setItems(selectedValue);
247: }
248:
249: /**
250: * <p>Restore the state of this component.</p>
251: */
252: public void restoreState(FacesContext _context, Object _state) {
253: Object _values[] = (Object[]) _state;
254: super .restoreState(_context, _values[0]);
255: this .imageURL = (String) _values[1];
256: this .name = (String) _values[2];
257: }
258:
259: /**
260: * <p>Save the state of this component.</p>
261: */
262: public Object saveState(FacesContext _context) {
263: Object _values[] = new Object[3];
264: _values[0] = super .saveState(_context);
265: _values[1] = this .imageURL;
266: _values[2] = this.name;
267: return _values;
268: }
269:
270: }
|