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>PropertySheet</code> component is a <code>NamingContainer</code>
053: * used to layout <code>PropertySheetSection</code> components on a page.
054: * Each <code>PropertySheetSection</code> may in turn have any number of
055: * <code>Property</code> components within it. This allows you to easily
056: * format a page with a number of input or read-only fields.
057: * <code>PropertySheetSection</code>s allow you to group <code>Property</code>
058: * components together and provide a <code>label</code> for the set of
059: * enclosed <code>Property</code>s.</p>
060: *
061: * <p> The <code>PropertySheet</code> allows each
062: * <code>PropertySheetSection</code> to have an optional "jump link" from the
063: * top of the <code>PropertySheet</code> to each
064: * <code>PropertySheetSection</code> within the <code>PropertySheet</code>.
065: * This is accomplished by supplying the attribute <code>jumpLinks</code> with
066: * a value of true. If not specified, this attribute defaults to false.</p>
067: *
068: * <h3>Client Side Javascript Functions</h3>
069: *
070: * <p> None.</p>
071: *
072: * <h3>Example:</h3>
073: *
074: * <h4>Example 1: Create a simple <code>PropertySheet</code> which contains 2 <code>PropertySheetSection</code> components each containing 2 <code>Property</code> components:</h4>
075: *
076: * <p>
077: * <code>
078: * <pre>
079: * <ui:propertySheet id="propSheetExample1" jumpLinks="true">
080: * <ui:propertySheetSection id="firstSection" label="Search Criteria">
081: * <ui:property id="Property1" label="Instance Name: " labelAlign="right" noWrap="true" overlapLabel="false">
082: * <ui:dropDown id="servers" required="true" items="#{BackingFileChoice.servers}" />
083: * <f:verbatim>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</f:verbatim>
084: * <ui:label id="logFileLabel" labelLevel="2" text="Log File: " />
085: * <ui:dropDown id="logFile" items="#{BackingFileChoice.archivedLogFiles}" />
086: * </ui:property>
087: * <ui:property id="Property2" label="Log Level: " labelAlign="right" noWrap="true" overlapLabel="false" helpText="#{bundle.['log.level.help']}">
088: * <f:facet name="content">
089: * <ui:dropDown id="logLevel" items="#{BackingFileChoice.logLevel}" />
090: * </f:facet>
091: * </ui:property>
092: * </ui:propertySheetSection>
093: * <ui:propertySheetSection id="secondSection" label="Advanced Options">
094: * <ui:property id="Property3" label="Logger: " labelAlign="right" noWrap="true" overlapLabel="false" helpText="Select one or more module logs to view">
095: * <ui:listbox id="logger" items="#{BackingFileChoice.loggers}" rows="5" />
096: * </ui:property>
097: * <ui:property id="Property4" noWrap="true" overlapLabel="false" helpText="Select one or more module logs to view">
098: * <ui:checkbox id="limitLongLogs" label="Limit excessively long messages" />
099: * </ui:property>
100: * </ui:propertySheetSection>
101: * </ui:propertySheet>
102: * </pre>
103: * </code>
104: * </p>
105: * <p>Auto-generated component class.
106: * Do <strong>NOT</strong> modify; all changes
107: * <strong>will</strong> be lost!</p>
108: */
109:
110: public abstract class PropertySheetBase extends
111: javax.faces.component.UIComponentBase {
112:
113: /**
114: * <p>Construct a new <code>PropertySheetBase</code>.</p>
115: */
116: public PropertySheetBase() {
117: super ();
118: setRendererType("com.sun.rave.web.ui.PropertySheet");
119: }
120:
121: /**
122: * <p>Return the identifier of the component family to which this
123: * component belongs. This identifier, in conjunction with the value
124: * of the <code>rendererType</code> property, may be used to select
125: * the appropriate {@link Renderer} for this component instance.</p>
126: */
127: public String getFamily() {
128: return "com.sun.rave.web.ui.PropertySheet";
129: }
130:
131: // jumpLinks
132: private boolean jumpLinks = false;
133: private boolean jumpLinks_set = false;
134:
135: /**
136: * <p> This boolean attribute allows you to control whether jump links
137: * will be created at the top of this <code>PropertySheet</code>
138: * or not. The default is NOT to create the links -- setting this
139: * attribute to "true" turns this feature on.</p>
140: */
141: public boolean isJumpLinks() {
142: if (this .jumpLinks_set) {
143: return this .jumpLinks;
144: }
145: ValueBinding _vb = getValueBinding("jumpLinks");
146: if (_vb != null) {
147: Object _result = _vb.getValue(getFacesContext());
148: if (_result == null) {
149: return false;
150: } else {
151: return ((Boolean) _result).booleanValue();
152: }
153: }
154: return false;
155: }
156:
157: /**
158: * <p> This boolean attribute allows you to control whether jump links
159: * will be created at the top of this <code>PropertySheet</code>
160: * or not. The default is NOT to create the links -- setting this
161: * attribute to "true" turns this feature on.</p>
162: * @see #isJumpLinks()
163: */
164: public void setJumpLinks(boolean jumpLinks) {
165: this .jumpLinks = jumpLinks;
166: this .jumpLinks_set = true;
167: }
168:
169: // requiredFields
170: private String requiredFields = null;
171:
172: /**
173: * <p>This property indicates whether a required field legend should be
174: * displayed at the top right-hand side of the property sheet.</p>
175: */
176: public String getRequiredFields() {
177: if (this .requiredFields != null) {
178: return this .requiredFields;
179: }
180: ValueBinding _vb = getValueBinding("requiredFields");
181: if (_vb != null) {
182: return (String) _vb.getValue(getFacesContext());
183: }
184: return null;
185: }
186:
187: /**
188: * <p>This property indicates whether a required field legend should be
189: * displayed at the top right-hand side of the property sheet.</p>
190: * @see #getRequiredFields()
191: */
192: public void setRequiredFields(String requiredFields) {
193: this .requiredFields = requiredFields;
194: }
195:
196: // style
197: private String style = null;
198:
199: /**
200: * <p>CSS style(s) to be applied when this component is rendered.</p>
201: */
202: public String getStyle() {
203: if (this .style != null) {
204: return this .style;
205: }
206: ValueBinding _vb = getValueBinding("style");
207: if (_vb != null) {
208: return (String) _vb.getValue(getFacesContext());
209: }
210: return null;
211: }
212:
213: /**
214: * <p>CSS style(s) to be applied when this component is rendered.</p>
215: * @see #getStyle()
216: */
217: public void setStyle(String style) {
218: this .style = style;
219: }
220:
221: // styleClass
222: private String styleClass = null;
223:
224: /**
225: * <p>CSS style class(es) to be applied when this component is rendered.</p>
226: */
227: public String getStyleClass() {
228: if (this .styleClass != null) {
229: return this .styleClass;
230: }
231: ValueBinding _vb = getValueBinding("styleClass");
232: if (_vb != null) {
233: return (String) _vb.getValue(getFacesContext());
234: }
235: return null;
236: }
237:
238: /**
239: * <p>CSS style class(es) to be applied when this component is rendered.</p>
240: * @see #getStyleClass()
241: */
242: public void setStyleClass(String styleClass) {
243: this .styleClass = styleClass;
244: }
245:
246: // visible
247: private boolean visible = false;
248: private boolean visible_set = false;
249:
250: /**
251: * <p>Use the visible attribute to indicate whether the component should be
252: * viewable by the user in the rendered HTML page. If set to false, the
253: * HTML code for the component is present in the page, but the component
254: * is hidden with style attributes. By default, visible is set to true, so
255: * HTML for the component HTML is included and visible to the user. If the
256: * component is not visible, it can still be processed on subsequent form
257: * submissions because the HTML is present.</p>
258: */
259: public boolean isVisible() {
260: if (this .visible_set) {
261: return this .visible;
262: }
263: ValueBinding _vb = getValueBinding("visible");
264: if (_vb != null) {
265: Object _result = _vb.getValue(getFacesContext());
266: if (_result == null) {
267: return false;
268: } else {
269: return ((Boolean) _result).booleanValue();
270: }
271: }
272: return true;
273: }
274:
275: /**
276: * <p>Use the visible attribute to indicate whether the component should be
277: * viewable by the user in the rendered HTML page. If set to false, the
278: * HTML code for the component is present in the page, but the component
279: * is hidden with style attributes. By default, visible is set to true, so
280: * HTML for the component HTML is included and visible to the user. If the
281: * component is not visible, it can still be processed on subsequent form
282: * submissions because the HTML is present.</p>
283: * @see #isVisible()
284: */
285: public void setVisible(boolean visible) {
286: this .visible = visible;
287: this .visible_set = true;
288: }
289:
290: /**
291: * <p>Restore the state of this component.</p>
292: */
293: public void restoreState(FacesContext _context, Object _state) {
294: Object _values[] = (Object[]) _state;
295: super .restoreState(_context, _values[0]);
296: this .jumpLinks = ((Boolean) _values[1]).booleanValue();
297: this .jumpLinks_set = ((Boolean) _values[2]).booleanValue();
298: this .requiredFields = (String) _values[3];
299: this .style = (String) _values[4];
300: this .styleClass = (String) _values[5];
301: this .visible = ((Boolean) _values[6]).booleanValue();
302: this .visible_set = ((Boolean) _values[7]).booleanValue();
303: }
304:
305: /**
306: * <p>Save the state of this component.</p>
307: */
308: public Object saveState(FacesContext _context) {
309: Object _values[] = new Object[8];
310: _values[0] = super .saveState(_context);
311: _values[1] = this .jumpLinks ? Boolean.TRUE : Boolean.FALSE;
312: _values[2] = this .jumpLinks_set ? Boolean.TRUE : Boolean.FALSE;
313: _values[3] = this .requiredFields;
314: _values[4] = this .style;
315: _values[5] = this .styleClass;
316: _values[6] = this .visible ? Boolean.TRUE : Boolean.FALSE;
317: _values[7] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
318: return _values;
319: }
320:
321: }
|