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: * <p> Use the <code>ui:panelGroup</code> tag to display a group of components
051: * that are separated by a common separator. This tag is often useful for
052: * providing a consistently formatted layout of a group of components.</p>
053: * <h3>HTML Elements and Layout</h3>
054: * <p> By default the PanelGroup component is rendered with a
055: * <code><span></code> element surrounding the group of child
056: * components. You can change the rendered element to a
057: * <code><div></code> by setting the <code>block</code> attribute to
058: * <code>true</code>. When a <code><div></code> is used, the
059: * panel group is displayed on a new line. Note that if you use a
060: * component in the <code>ui:panelGroup</code> tag that renders a block
061: * element such as a <code><p></code>, that component is always
062: * displayed on its own line. The behavior of child block elements is
063: * independent of the setting of the block attribute.</p>
064: *
065: * <p> PanelGroup is a NamingContainer.</p>
066: *
067: * <h3>Theme Identifiers</h3>
068: *
069: * <p> Not Applicable </p>
070: *
071: * <h3>Client Side Javascript Functions</h3>
072: *
073: * <p> Not Applicable </p>
074: *
075: * <h3>Examples:</h3>
076: *
077: * <h4>Example 1: Buttons in a panelGroup that uses default separator</h4>
078: *
079: * <p> The default separator is a return character.</p>
080: *
081: * <code>
082: * <ui:panelGroup id="myPanelGroup1"><br />
083: *
084: * <ui:button id="button1" text="Button 1" /><br />
085: *
086: * <ui:button id="button2" text="Button 2" /><br />
087: *
088: * <ui:button id="button3" text="Button 3" /><br />
089: *
090: * <ui:button id="button4" text="Button 4" /><br />
091: * </ui:panelGroup>
092: * </code>
093: *
094: * <h4>Example 2: Specifying a separator with the <code>separator</code>
095: * attribute</h4>
096: *
097: * <p> This example uses the separator attribute to specify a separator
098: * consisting of a pipe character surrounded by spaces.</p>
099: *
100: * <code>
101: * <ui:panelGroup id="myPanelGroup2" separator=" | "><br />
102: *
103: * <ui:button id="button1" text="Button 1" /><br />
104: *
105: * <ui:button id="button2" text="Button 2" /><br />
106: *
107: * <ui:button id="button3" text="Button 3" /><br />
108: *
109: * <ui:button id="button4" text="Button 4" /><br />
110: * </ui:panelGroup>
111: * </code>
112: *
113: * <h4>Example 3: Specifying a separator with the <code>separator</code>
114: * facet</h4>
115: *
116: * <p> This example shows how to use the <code>separator</code> facet and
117: * the <code>block</code> attribute.</p>
118: *
119: * <code>
120: * <ui:panelGroup id="myPanelGroup3" block="true"><br />
121: *
122: * <facet name="separator"><br />
123: *
124: * <h:outputText value="==" /><br />
125: *
126: * </f:facet><br />
127: *
128: * <ui:button id="button1" text="Button 1" /><br />
129: *
130: * <ui:button id="button2" text="Button 2" /><br />
131: *
132: * <ui:button id="button3" text="Button 3" /><br />
133: *
134: * <ui:button id="button4" text="Button 4" /><br />
135: * </ui:panelGroup>
136: * </code>
137: * <p>Auto-generated component class.
138: * Do <strong>NOT</strong> modify; all changes
139: * <strong>will</strong> be lost!</p>
140: */
141:
142: public abstract class PanelGroupBase extends
143: javax.faces.component.UIComponentBase {
144:
145: /**
146: * <p>Construct a new <code>PanelGroupBase</code>.</p>
147: */
148: public PanelGroupBase() {
149: super ();
150: setRendererType("com.sun.rave.web.ui.PanelGroup");
151: }
152:
153: /**
154: * <p>Return the identifier of the component family to which this
155: * component belongs. This identifier, in conjunction with the value
156: * of the <code>rendererType</code> property, may be used to select
157: * the appropriate {@link Renderer} for this component instance.</p>
158: */
159: public String getFamily() {
160: return "com.sun.rave.web.ui.PanelGroup";
161: }
162:
163: // block
164: private boolean block = false;
165: private boolean block_set = false;
166:
167: /**
168: * <p>By default, the panelGroup component is rendered on the same line as the component
169: * that comes before it and the component that follows, in a flow layout. If the block attribute
170: * is set to true, the panelGroup component is rendered on its own line. The components
171: * before it and after it are on different lines. The block attribute has no effect on the
172: * panelGroup component's children.</p>
173: */
174: public boolean isBlock() {
175: if (this .block_set) {
176: return this .block;
177: }
178: ValueBinding _vb = getValueBinding("block");
179: if (_vb != null) {
180: Object _result = _vb.getValue(getFacesContext());
181: if (_result == null) {
182: return false;
183: } else {
184: return ((Boolean) _result).booleanValue();
185: }
186: }
187: return false;
188: }
189:
190: /**
191: * <p>By default, the panelGroup component is rendered on the same line as the component
192: * that comes before it and the component that follows, in a flow layout. If the block attribute
193: * is set to true, the panelGroup component is rendered on its own line. The components
194: * before it and after it are on different lines. The block attribute has no effect on the
195: * panelGroup component's children.</p>
196: * @see #isBlock()
197: */
198: public void setBlock(boolean block) {
199: this .block = block;
200: this .block_set = true;
201: }
202:
203: // separator
204: private String separator = null;
205:
206: /**
207: * <p>The String of characters that should be inserted between each UIComponent that is
208: * a child of this component. If this attribute is not specified, then a newline will be
209: * inserted between each component.</p>
210: */
211: public String getSeparator() {
212: if (this .separator != null) {
213: return this .separator;
214: }
215: ValueBinding _vb = getValueBinding("separator");
216: if (_vb != null) {
217: return (String) _vb.getValue(getFacesContext());
218: }
219: return null;
220: }
221:
222: /**
223: * <p>The String of characters that should be inserted between each UIComponent that is
224: * a child of this component. If this attribute is not specified, then a newline will be
225: * inserted between each component.</p>
226: * @see #getSeparator()
227: */
228: public void setSeparator(String separator) {
229: this .separator = separator;
230: }
231:
232: // style
233: private String style = null;
234:
235: /**
236: * <p>CSS style(s) to be applied when this component is rendered.</p>
237: */
238: public String getStyle() {
239: if (this .style != null) {
240: return this .style;
241: }
242: ValueBinding _vb = getValueBinding("style");
243: if (_vb != null) {
244: return (String) _vb.getValue(getFacesContext());
245: }
246: return null;
247: }
248:
249: /**
250: * <p>CSS style(s) to be applied when this component is rendered.</p>
251: * @see #getStyle()
252: */
253: public void setStyle(String style) {
254: this .style = style;
255: }
256:
257: // styleClass
258: private String styleClass = null;
259:
260: /**
261: * <p>CSS style class(es) to be applied when this component is rendered.</p>
262: */
263: public String getStyleClass() {
264: if (this .styleClass != null) {
265: return this .styleClass;
266: }
267: ValueBinding _vb = getValueBinding("styleClass");
268: if (_vb != null) {
269: return (String) _vb.getValue(getFacesContext());
270: }
271: return null;
272: }
273:
274: /**
275: * <p>CSS style class(es) to be applied when this component is rendered.</p>
276: * @see #getStyleClass()
277: */
278: public void setStyleClass(String styleClass) {
279: this .styleClass = styleClass;
280: }
281:
282: // visible
283: private boolean visible = false;
284: private boolean visible_set = false;
285:
286: /**
287: * <p>Use the visible attribute to indicate whether the component should be
288: * viewable by the user in the rendered HTML page. If set to false, the
289: * HTML code for the component is present in the page, but the component
290: * is hidden with style attributes. By default, visible is set to true, so
291: * HTML for the component HTML is included and visible to the user. If the
292: * component is not visible, it can still be processed on subsequent form
293: * submissions because the HTML is present.</p>
294: */
295: public boolean isVisible() {
296: if (this .visible_set) {
297: return this .visible;
298: }
299: ValueBinding _vb = getValueBinding("visible");
300: if (_vb != null) {
301: Object _result = _vb.getValue(getFacesContext());
302: if (_result == null) {
303: return false;
304: } else {
305: return ((Boolean) _result).booleanValue();
306: }
307: }
308: return true;
309: }
310:
311: /**
312: * <p>Use the visible attribute to indicate whether the component should be
313: * viewable by the user in the rendered HTML page. If set to false, the
314: * HTML code for the component is present in the page, but the component
315: * is hidden with style attributes. By default, visible is set to true, so
316: * HTML for the component HTML is included and visible to the user. If the
317: * component is not visible, it can still be processed on subsequent form
318: * submissions because the HTML is present.</p>
319: * @see #isVisible()
320: */
321: public void setVisible(boolean visible) {
322: this .visible = visible;
323: this .visible_set = true;
324: }
325:
326: /**
327: * <p>Restore the state of this component.</p>
328: */
329: public void restoreState(FacesContext _context, Object _state) {
330: Object _values[] = (Object[]) _state;
331: super .restoreState(_context, _values[0]);
332: this .block = ((Boolean) _values[1]).booleanValue();
333: this .block_set = ((Boolean) _values[2]).booleanValue();
334: this .separator = (String) _values[3];
335: this .style = (String) _values[4];
336: this .styleClass = (String) _values[5];
337: this .visible = ((Boolean) _values[6]).booleanValue();
338: this .visible_set = ((Boolean) _values[7]).booleanValue();
339: }
340:
341: /**
342: * <p>Save the state of this component.</p>
343: */
344: public Object saveState(FacesContext _context) {
345: Object _values[] = new Object[8];
346: _values[0] = super .saveState(_context);
347: _values[1] = this .block ? Boolean.TRUE : Boolean.FALSE;
348: _values[2] = this .block_set ? Boolean.TRUE : Boolean.FALSE;
349: _values[3] = this .separator;
350: _values[4] = this .style;
351: _values[5] = this .styleClass;
352: _values[6] = this .visible ? Boolean.TRUE : Boolean.FALSE;
353: _values[7] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
354: return _values;
355: }
356:
357: }
|