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: * <h3>HTML Elements and Layout</h3>
051: *
052: * <p> The <code>PropertySheetSection</code> component was written to be used
053: * within the <code>PropertySheet</code> component. It allows you to group
054: * <code>Property<code> components together in sections within the
055: * <code>PropertySheet</code> component.</p>
056: *
057: * <p> When you use this component to create a grouping of <code>Property</code>
058: * components, you may provide a description for the
059: * <code>PropertySheetSection</code>. This is done via the
060: * <code>label</code> attribute. Set this attribute to the desired value,
061: * which, of course, may be a ValueBinding expression or a literal String.</p>
062: *
063: * <h3>Client Side Javascript Functions</h3>
064: *
065: * <p> None.</p>
066: *
067: * <h3>Example:</h3>
068: *
069: * <p> For an example, please see the documentation for the <code>propertySheet</code> Tag.</p>
070: * <p>Auto-generated component class.
071: * Do <strong>NOT</strong> modify; all changes
072: * <strong>will</strong> be lost!</p>
073: */
074:
075: public abstract class PropertySheetSectionBase extends
076: javax.faces.component.UIComponentBase {
077:
078: /**
079: * <p>Construct a new <code>PropertySheetSectionBase</code>.</p>
080: */
081: public PropertySheetSectionBase() {
082: super ();
083: setRendererType("com.sun.rave.web.ui.PropertySheetSection");
084: }
085:
086: /**
087: * <p>Return the identifier of the component family to which this
088: * component belongs. This identifier, in conjunction with the value
089: * of the <code>rendererType</code> property, may be used to select
090: * the appropriate {@link Renderer} for this component instance.</p>
091: */
092: public String getFamily() {
093: return "com.sun.rave.web.ui.PropertySheetSection";
094: }
095:
096: // label
097: private String label = null;
098:
099: /**
100: * <p> This attribute allows you to provide a label or title for the section
101: * this <code>PropertySheetSection</code> defines for the<code>PropertySheet</code> component. The value may be a literal
102: * String, or it may be a ValueBinding expression (useful for
103: * localization).</p>
104: */
105: public String getLabel() {
106: if (this .label != null) {
107: return this .label;
108: }
109: ValueBinding _vb = getValueBinding("label");
110: if (_vb != null) {
111: return (String) _vb.getValue(getFacesContext());
112: }
113: return null;
114: }
115:
116: /**
117: * <p> This attribute allows you to provide a label or title for the section
118: * this <code>PropertySheetSection</code> defines for the<code>PropertySheet</code> component. The value may be a literal
119: * String, or it may be a ValueBinding expression (useful for
120: * localization).</p>
121: * @see #getLabel()
122: */
123: public void setLabel(String label) {
124: this .label = label;
125: }
126:
127: // style
128: private String style = null;
129:
130: /**
131: * <p>CSS style(s) to be applied when this component is rendered.</p>
132: */
133: public String getStyle() {
134: if (this .style != null) {
135: return this .style;
136: }
137: ValueBinding _vb = getValueBinding("style");
138: if (_vb != null) {
139: return (String) _vb.getValue(getFacesContext());
140: }
141: return null;
142: }
143:
144: /**
145: * <p>CSS style(s) to be applied when this component is rendered.</p>
146: * @see #getStyle()
147: */
148: public void setStyle(String style) {
149: this .style = style;
150: }
151:
152: // styleClass
153: private String styleClass = null;
154:
155: /**
156: * <p>CSS style class(es) to be applied when this component is rendered.</p>
157: */
158: public String getStyleClass() {
159: if (this .styleClass != null) {
160: return this .styleClass;
161: }
162: ValueBinding _vb = getValueBinding("styleClass");
163: if (_vb != null) {
164: return (String) _vb.getValue(getFacesContext());
165: }
166: return null;
167: }
168:
169: /**
170: * <p>CSS style class(es) to be applied when this component is rendered.</p>
171: * @see #getStyleClass()
172: */
173: public void setStyleClass(String styleClass) {
174: this .styleClass = styleClass;
175: }
176:
177: // visible
178: private boolean visible = false;
179: private boolean visible_set = false;
180:
181: /**
182: * <p>Use the visible attribute to indicate whether the component should be
183: * viewable by the user in the rendered HTML page. If set to false, the
184: * HTML code for the component is present in the page, but the component
185: * is hidden with style attributes. By default, visible is set to true, so
186: * HTML for the component HTML is included and visible to the user. If the
187: * component is not visible, it can still be processed on subsequent form
188: * submissions because the HTML is present.</p>
189: */
190: public boolean isVisible() {
191: if (this .visible_set) {
192: return this .visible;
193: }
194: ValueBinding _vb = getValueBinding("visible");
195: if (_vb != null) {
196: Object _result = _vb.getValue(getFacesContext());
197: if (_result == null) {
198: return false;
199: } else {
200: return ((Boolean) _result).booleanValue();
201: }
202: }
203: return true;
204: }
205:
206: /**
207: * <p>Use the visible attribute to indicate whether the component should be
208: * viewable by the user in the rendered HTML page. If set to false, the
209: * HTML code for the component is present in the page, but the component
210: * is hidden with style attributes. By default, visible is set to true, so
211: * HTML for the component HTML is included and visible to the user. If the
212: * component is not visible, it can still be processed on subsequent form
213: * submissions because the HTML is present.</p>
214: * @see #isVisible()
215: */
216: public void setVisible(boolean visible) {
217: this .visible = visible;
218: this .visible_set = true;
219: }
220:
221: /**
222: * <p>Restore the state of this component.</p>
223: */
224: public void restoreState(FacesContext _context, Object _state) {
225: Object _values[] = (Object[]) _state;
226: super .restoreState(_context, _values[0]);
227: this .label = (String) _values[1];
228: this .style = (String) _values[2];
229: this .styleClass = (String) _values[3];
230: this .visible = ((Boolean) _values[4]).booleanValue();
231: this .visible_set = ((Boolean) _values[5]).booleanValue();
232: }
233:
234: /**
235: * <p>Save the state of this component.</p>
236: */
237: public Object saveState(FacesContext _context) {
238: Object _values[] = new Object[6];
239: _values[0] = super .saveState(_context);
240: _values[1] = this .label;
241: _values[2] = this .style;
242: _values[3] = this .styleClass;
243: _values[4] = this .visible ? Boolean.TRUE : Boolean.FALSE;
244: _values[5] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
245: return _values;
246: }
247:
248: }
|