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: * Base component for UI components that allow the user to make a
051: * selection from a list of options using an HTML select element.
052: * <p>Auto-generated component class.
053: * Do <strong>NOT</strong> modify; all changes
054: * <strong>will</strong> be lost!</p>
055: */
056:
057: public abstract class ListSelectorBase extends
058: com.sun.rave.web.ui.component.Selector {
059:
060: /**
061: * <p>Construct a new <code>ListSelectorBase</code>.</p>
062: */
063: public ListSelectorBase() {
064: super ();
065: setRendererType("com.sun.rave.web.ui.ListSelectorRenderer");
066: }
067:
068: /**
069: * <p>Return the identifier of the component family to which this
070: * component belongs. This identifier, in conjunction with the value
071: * of the <code>rendererType</code> property, may be used to select
072: * the appropriate {@link Renderer} for this component instance.</p>
073: */
074: public String getFamily() {
075: return "com.sun.rave.web.ui.ListSelector";
076: }
077:
078: // labelOnTop
079: private boolean labelOnTop = false;
080: private boolean labelOnTop_set = false;
081:
082: /**
083: * <p>If this attribute is true, the label is rendered above the
084: * component. If it is false, the label is rendered next to the
085: * component. The default is false.</p>
086: */
087: public boolean isLabelOnTop() {
088: if (this .labelOnTop_set) {
089: return this .labelOnTop;
090: }
091: ValueBinding _vb = getValueBinding("labelOnTop");
092: if (_vb != null) {
093: Object _result = _vb.getValue(getFacesContext());
094: if (_result == null) {
095: return false;
096: } else {
097: return ((Boolean) _result).booleanValue();
098: }
099: }
100: return false;
101: }
102:
103: /**
104: * <p>If this attribute is true, the label is rendered above the
105: * component. If it is false, the label is rendered next to the
106: * component. The default is false.</p>
107: * @see #isLabelOnTop()
108: */
109: public void setLabelOnTop(boolean labelOnTop) {
110: this .labelOnTop = labelOnTop;
111: this .labelOnTop_set = true;
112: }
113:
114: // rows
115: private int rows = Integer.MIN_VALUE;
116: private boolean rows_set = false;
117:
118: /**
119: * <p>The number of items to display. The default value is 12.</p>
120: */
121: public int getRows() {
122: if (this .rows_set) {
123: return this .rows;
124: }
125: ValueBinding _vb = getValueBinding("rows");
126: if (_vb != null) {
127: Object _result = _vb.getValue(getFacesContext());
128: if (_result == null) {
129: return Integer.MIN_VALUE;
130: } else {
131: return ((Integer) _result).intValue();
132: }
133: }
134: return 12;
135: }
136:
137: /**
138: * <p>The number of items to display. The default value is 12.</p>
139: * @see #getRows()
140: */
141: public void setRows(int rows) {
142: this .rows = rows;
143: this .rows_set = true;
144: }
145:
146: // separators
147: private boolean separators = false;
148: private boolean separators_set = false;
149:
150: /**
151: * <p>Flag indicating that items corresponding to
152: * <code>com.sun.rave.web.ui.model.Option</code> that are defined
153: * inside a <code>com.sun.rave.web.ui.model.OptionGroup</code> should be
154: * surrounded by separators inside the list. The default value is
155: * true. If false, no separators are shown. To manually specify the
156: * location of separators, set this flag to false and place
157: * instances of <code>com.sun.rave.web.ui.model.Separator</code> between
158: * the relevant <code>com.sun.rave.web.ui.model.Option</code> instances
159: * when specifying the <code>items</code> attribute.</p>
160: */
161: public boolean isSeparators() {
162: if (this .separators_set) {
163: return this .separators;
164: }
165: ValueBinding _vb = getValueBinding("separators");
166: if (_vb != null) {
167: Object _result = _vb.getValue(getFacesContext());
168: if (_result == null) {
169: return false;
170: } else {
171: return ((Boolean) _result).booleanValue();
172: }
173: }
174: return true;
175: }
176:
177: /**
178: * <p>Flag indicating that items corresponding to
179: * <code>com.sun.rave.web.ui.model.Option</code> that are defined
180: * inside a <code>com.sun.rave.web.ui.model.OptionGroup</code> should be
181: * surrounded by separators inside the list. The default value is
182: * true. If false, no separators are shown. To manually specify the
183: * location of separators, set this flag to false and place
184: * instances of <code>com.sun.rave.web.ui.model.Separator</code> between
185: * the relevant <code>com.sun.rave.web.ui.model.Option</code> instances
186: * when specifying the <code>items</code> attribute.</p>
187: * @see #isSeparators()
188: */
189: public void setSeparators(boolean separators) {
190: this .separators = separators;
191: this .separators_set = true;
192: }
193:
194: // visible
195: private boolean visible = false;
196: private boolean visible_set = false;
197:
198: /**
199: * <p>Use the visible attribute to indicate whether the component should be
200: * viewable by the user in the rendered HTML page. If set to false, the
201: * HTML code for the component is present in the page, but the component
202: * is hidden with style attributes. By default, visible is set to true, so
203: * HTML for the component HTML is included and visible to the user. If the
204: * component is not visible, it can still be processed on subsequent form
205: * submissions because the HTML is present.</p>
206: */
207: public boolean isVisible() {
208: if (this .visible_set) {
209: return this .visible;
210: }
211: ValueBinding _vb = getValueBinding("visible");
212: if (_vb != null) {
213: Object _result = _vb.getValue(getFacesContext());
214: if (_result == null) {
215: return false;
216: } else {
217: return ((Boolean) _result).booleanValue();
218: }
219: }
220: return true;
221: }
222:
223: /**
224: * <p>Use the visible attribute to indicate whether the component should be
225: * viewable by the user in the rendered HTML page. If set to false, the
226: * HTML code for the component is present in the page, but the component
227: * is hidden with style attributes. By default, visible is set to true, so
228: * HTML for the component HTML is included and visible to the user. If the
229: * component is not visible, it can still be processed on subsequent form
230: * submissions because the HTML is present.</p>
231: * @see #isVisible()
232: */
233: public void setVisible(boolean visible) {
234: this .visible = visible;
235: this .visible_set = true;
236: }
237:
238: /**
239: * <p>Restore the state of this component.</p>
240: */
241: public void restoreState(FacesContext _context, Object _state) {
242: Object _values[] = (Object[]) _state;
243: super .restoreState(_context, _values[0]);
244: this .labelOnTop = ((Boolean) _values[1]).booleanValue();
245: this .labelOnTop_set = ((Boolean) _values[2]).booleanValue();
246: this .rows = ((Integer) _values[3]).intValue();
247: this .rows_set = ((Boolean) _values[4]).booleanValue();
248: this .separators = ((Boolean) _values[5]).booleanValue();
249: this .separators_set = ((Boolean) _values[6]).booleanValue();
250: this .visible = ((Boolean) _values[7]).booleanValue();
251: this .visible_set = ((Boolean) _values[8]).booleanValue();
252: }
253:
254: /**
255: * <p>Save the state of this component.</p>
256: */
257: public Object saveState(FacesContext _context) {
258: Object _values[] = new Object[9];
259: _values[0] = super .saveState(_context);
260: _values[1] = this .labelOnTop ? Boolean.TRUE : Boolean.FALSE;
261: _values[2] = this .labelOnTop_set ? Boolean.TRUE : Boolean.FALSE;
262: _values[3] = new Integer(this .rows);
263: _values[4] = this .rows_set ? Boolean.TRUE : Boolean.FALSE;
264: _values[5] = this .separators ? Boolean.TRUE : Boolean.FALSE;
265: _values[6] = this .separators_set ? Boolean.TRUE : Boolean.FALSE;
266: _values[7] = this .visible ? Boolean.TRUE : Boolean.FALSE;
267: _values[8] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
268: return _values;
269: }
270:
271: }
|