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: * Use the <code>ui:legend</code>
051: * tag to display legend, typically at the top of a page.
052: * <br>
053: * The legend tag has one facet:<br>
054: * <code>legendImage</code> - this allows the developer to place their own image and/or text in the legend.<br>
055: * <h3>HTML Elements and Layout</h3>
056: * A legend consists of an icon/image followed by explanatory text describing the icon/image.
057: * <h3>Client Side Javascript Functions</h3>
058: * none.
059: * <h3>Examples</h3>
060: * <b>Example 1: An example showing the default (indicates required field) legend:</b> <br>
061: * <code>
062: * <ui:legend id="legend1" />
063: * </code>
064: * <br><br>
065: * <b>Example 2: An example showing a custom icon, text, styles:</b> <br>
066: * <pre>
067: * <code><ui:legend id="legend2" text="Critical Alarms"
068: * style="position: absolute; left:100px; color:red; font-weight:bold"/>
069: * <f:facet name="legendImage">
070: * ui:image id="alarmimage" icon="ALARM_CRITICAL_SMALL" alt="Critical Alarm"/>
071: * </f:facet>
072: * </ui:legend>
073: * </code>
074: * </pre>
075: * <br>
076: * <p>Auto-generated component class.
077: * Do <strong>NOT</strong> modify; all changes
078: * <strong>will</strong> be lost!</p>
079: */
080:
081: public abstract class LegendBase extends javax.faces.component.UIOutput {
082:
083: /**
084: * <p>Construct a new <code>LegendBase</code>.</p>
085: */
086: public LegendBase() {
087: super ();
088: setRendererType("com.sun.rave.web.ui.Legend");
089: }
090:
091: /**
092: * <p>Return the identifier of the component family to which this
093: * component belongs. This identifier, in conjunction with the value
094: * of the <code>rendererType</code> property, may be used to select
095: * the appropriate {@link Renderer} for this component instance.</p>
096: */
097: public String getFamily() {
098: return "com.sun.rave.web.ui.Legend";
099: }
100:
101: // position
102: private String position = null;
103:
104: /**
105: * <p>Specifies the position of the legend. Valid values are: "right" (the default) and "left".</p>
106: */
107: public String getPosition() {
108: if (this .position != null) {
109: return this .position;
110: }
111: ValueBinding _vb = getValueBinding("position");
112: if (_vb != null) {
113: return (String) _vb.getValue(getFacesContext());
114: }
115: return null;
116: }
117:
118: /**
119: * <p>Specifies the position of the legend. Valid values are: "right" (the default) and "left".</p>
120: * @see #getPosition()
121: */
122: public void setPosition(String position) {
123: this .position = position;
124: }
125:
126: // style
127: private String style = null;
128:
129: /**
130: * <p>CSS style(s) to be applied when this component is rendered.</p>
131: */
132: public String getStyle() {
133: if (this .style != null) {
134: return this .style;
135: }
136: ValueBinding _vb = getValueBinding("style");
137: if (_vb != null) {
138: return (String) _vb.getValue(getFacesContext());
139: }
140: return null;
141: }
142:
143: /**
144: * <p>CSS style(s) to be applied when this component is rendered.</p>
145: * @see #getStyle()
146: */
147: public void setStyle(String style) {
148: this .style = style;
149: }
150:
151: // styleClass
152: private String styleClass = null;
153:
154: /**
155: * <p>CSS style class(es) to be applied when this component is rendered.</p>
156: */
157: public String getStyleClass() {
158: if (this .styleClass != null) {
159: return this .styleClass;
160: }
161: ValueBinding _vb = getValueBinding("styleClass");
162: if (_vb != null) {
163: return (String) _vb.getValue(getFacesContext());
164: }
165: return null;
166: }
167:
168: /**
169: * <p>CSS style class(es) to be applied when this component is rendered.</p>
170: * @see #getStyleClass()
171: */
172: public void setStyleClass(String styleClass) {
173: this .styleClass = styleClass;
174: }
175:
176: // text
177: private String text = null;
178:
179: /**
180: * <p>The explanatory text that is displayed in the legend. If not specified, the required field legend text is displayed.</p>
181: */
182: public String getText() {
183: if (this .text != null) {
184: return this .text;
185: }
186: ValueBinding _vb = getValueBinding("text");
187: if (_vb != null) {
188: return (String) _vb.getValue(getFacesContext());
189: }
190: return null;
191: }
192:
193: /**
194: * <p>The explanatory text that is displayed in the legend. If not specified, the required field legend text is displayed.</p>
195: * @see #getText()
196: */
197: public void setText(String text) {
198: this .text = text;
199: }
200:
201: // visible
202: private boolean visible = false;
203: private boolean visible_set = false;
204:
205: /**
206: * <p>Use the visible attribute to indicate whether the component should be
207: * viewable by the user in the rendered HTML page. If set to false, the
208: * HTML code for the component is present in the page, but the component
209: * is hidden with style attributes. By default, visible is set to true, so
210: * HTML for the component HTML is included and visible to the user. If the
211: * component is not visible, it can still be processed on subsequent form
212: * submissions because the HTML is present.</p>
213: */
214: public boolean isVisible() {
215: if (this .visible_set) {
216: return this .visible;
217: }
218: ValueBinding _vb = getValueBinding("visible");
219: if (_vb != null) {
220: Object _result = _vb.getValue(getFacesContext());
221: if (_result == null) {
222: return false;
223: } else {
224: return ((Boolean) _result).booleanValue();
225: }
226: }
227: return true;
228: }
229:
230: /**
231: * <p>Use the visible attribute to indicate whether the component should be
232: * viewable by the user in the rendered HTML page. If set to false, the
233: * HTML code for the component is present in the page, but the component
234: * is hidden with style attributes. By default, visible is set to true, so
235: * HTML for the component HTML is included and visible to the user. If the
236: * component is not visible, it can still be processed on subsequent form
237: * submissions because the HTML is present.</p>
238: * @see #isVisible()
239: */
240: public void setVisible(boolean visible) {
241: this .visible = visible;
242: this .visible_set = true;
243: }
244:
245: /**
246: * <p>Restore the state of this component.</p>
247: */
248: public void restoreState(FacesContext _context, Object _state) {
249: Object _values[] = (Object[]) _state;
250: super .restoreState(_context, _values[0]);
251: this .position = (String) _values[1];
252: this .style = (String) _values[2];
253: this .styleClass = (String) _values[3];
254: this .text = (String) _values[4];
255: this .visible = ((Boolean) _values[5]).booleanValue();
256: this .visible_set = ((Boolean) _values[6]).booleanValue();
257: }
258:
259: /**
260: * <p>Save the state of this component.</p>
261: */
262: public Object saveState(FacesContext _context) {
263: Object _values[] = new Object[7];
264: _values[0] = super .saveState(_context);
265: _values[1] = this .position;
266: _values[2] = this .style;
267: _values[3] = this .styleClass;
268: _values[4] = this .text;
269: _values[5] = this .visible ? Boolean.TRUE : Boolean.FALSE;
270: _values[6] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
271: return _values;
272: }
273:
274: }
|