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:messageGroup</code> tag to display a list of messages that are not (necessarily) associated with any single component.<br>
051: * <h3>HTML Elements and Layout</h3>
052: * A message group consists of a list of messages. <br>
053: * <h3>Client Side Javascript Functions</h3>
054: * none.<br>
055: * <h3>Examples</h3>
056: * <b>Example 1: An example showing how to show a list of global errors at the top of the page:</b> <br>
057: * <code><br>
058: * <ui:messageGroup showGlobalOnly="true"/><br>
059: * <br>
060: * <ui:staticText text="Validator checks that the value is between 0-10 inclusive. /><br>
061: * <ui:message for="form1:textTest1"/><br>
062: * <br>
063: * <ui:field id="textTest1" label="Enter a number:"
064: * text="#{FieldTest.number}" validator="#{FieldTest.checkNumber}"/><br>
065: * </code>
066: * <br>
067: * <p>Auto-generated component class.
068: * Do <strong>NOT</strong> modify; all changes
069: * <strong>will</strong> be lost!</p>
070: */
071:
072: public abstract class MessageGroupBase extends
073: javax.faces.component.UIComponentBase {
074:
075: /**
076: * <p>Construct a new <code>MessageGroupBase</code>.</p>
077: */
078: public MessageGroupBase() {
079: super ();
080: setRendererType("com.sun.rave.web.ui.MessageGroup");
081: }
082:
083: /**
084: * <p>Return the identifier of the component family to which this
085: * component belongs. This identifier, in conjunction with the value
086: * of the <code>rendererType</code> property, may be used to select
087: * the appropriate {@link Renderer} for this component instance.</p>
088: */
089: public String getFamily() {
090: return "com.sun.rave.web.ui.MessageGroup";
091: }
092:
093: // showDetail
094: private boolean showDetail = false;
095: private boolean showDetail_set = false;
096:
097: /**
098: * <p>Flag to determine whether to show the detail message.</p>
099: */
100: public boolean isShowDetail() {
101: if (this .showDetail_set) {
102: return this .showDetail;
103: }
104: ValueBinding _vb = getValueBinding("showDetail");
105: if (_vb != null) {
106: Object _result = _vb.getValue(getFacesContext());
107: if (_result == null) {
108: return false;
109: } else {
110: return ((Boolean) _result).booleanValue();
111: }
112: }
113: return false;
114: }
115:
116: /**
117: * <p>Flag to determine whether to show the detail message.</p>
118: * @see #isShowDetail()
119: */
120: public void setShowDetail(boolean showDetail) {
121: this .showDetail = showDetail;
122: this .showDetail_set = true;
123: }
124:
125: // showGlobalOnly
126: private boolean showGlobalOnly = false;
127: private boolean showGlobalOnly_set = false;
128:
129: /**
130: * <p>Flag to determine whether to show the global message.</p>
131: */
132: public boolean isShowGlobalOnly() {
133: if (this .showGlobalOnly_set) {
134: return this .showGlobalOnly;
135: }
136: ValueBinding _vb = getValueBinding("showGlobalOnly");
137: if (_vb != null) {
138: Object _result = _vb.getValue(getFacesContext());
139: if (_result == null) {
140: return false;
141: } else {
142: return ((Boolean) _result).booleanValue();
143: }
144: }
145: return false;
146: }
147:
148: /**
149: * <p>Flag to determine whether to show the global message.</p>
150: * @see #isShowGlobalOnly()
151: */
152: public void setShowGlobalOnly(boolean showGlobalOnly) {
153: this .showGlobalOnly = showGlobalOnly;
154: this .showGlobalOnly_set = true;
155: }
156:
157: // showSummary
158: private boolean showSummary = false;
159: private boolean showSummary_set = false;
160:
161: /**
162: * <p>Flag to determine whether to show the summary message.</p>
163: */
164: public boolean isShowSummary() {
165: if (this .showSummary_set) {
166: return this .showSummary;
167: }
168: ValueBinding _vb = getValueBinding("showSummary");
169: if (_vb != null) {
170: Object _result = _vb.getValue(getFacesContext());
171: if (_result == null) {
172: return false;
173: } else {
174: return ((Boolean) _result).booleanValue();
175: }
176: }
177: return true;
178: }
179:
180: /**
181: * <p>Flag to determine whether to show the summary message.</p>
182: * @see #isShowSummary()
183: */
184: public void setShowSummary(boolean showSummary) {
185: this .showSummary = showSummary;
186: this .showSummary_set = true;
187: }
188:
189: // style
190: private String style = null;
191:
192: /**
193: * <p>CSS style(s) to be applied when this component is rendered.</p>
194: */
195: public String getStyle() {
196: if (this .style != null) {
197: return this .style;
198: }
199: ValueBinding _vb = getValueBinding("style");
200: if (_vb != null) {
201: return (String) _vb.getValue(getFacesContext());
202: }
203: return null;
204: }
205:
206: /**
207: * <p>CSS style(s) to be applied when this component is rendered.</p>
208: * @see #getStyle()
209: */
210: public void setStyle(String style) {
211: this .style = style;
212: }
213:
214: // styleClass
215: private String styleClass = null;
216:
217: /**
218: * <p>CSS style class(es) to be applied when this component is rendered.</p>
219: */
220: public String getStyleClass() {
221: if (this .styleClass != null) {
222: return this .styleClass;
223: }
224: ValueBinding _vb = getValueBinding("styleClass");
225: if (_vb != null) {
226: return (String) _vb.getValue(getFacesContext());
227: }
228: return null;
229: }
230:
231: /**
232: * <p>CSS style class(es) to be applied when this component is rendered.</p>
233: * @see #getStyleClass()
234: */
235: public void setStyleClass(String styleClass) {
236: this .styleClass = styleClass;
237: }
238:
239: // toolTip
240: private String toolTip = null;
241:
242: /**
243: * <p>Display the text as a tooltip for this component</p>
244: */
245: public String getToolTip() {
246: if (this .toolTip != null) {
247: return this .toolTip;
248: }
249: ValueBinding _vb = getValueBinding("toolTip");
250: if (_vb != null) {
251: return (String) _vb.getValue(getFacesContext());
252: }
253: return null;
254: }
255:
256: /**
257: * <p>Display the text as a tooltip for this component</p>
258: * @see #getToolTip()
259: */
260: public void setToolTip(String toolTip) {
261: this .toolTip = toolTip;
262: }
263:
264: // visible
265: private boolean visible = false;
266: private boolean visible_set = false;
267:
268: /**
269: * <p>Use the visible attribute to indicate whether the component should be
270: * viewable by the user in the rendered HTML page. If set to false, the
271: * HTML code for the component is present in the page, but the component
272: * is hidden with style attributes. By default, visible is set to true, so
273: * HTML for the component HTML is included and visible to the user. If the
274: * component is not visible, it can still be processed on subsequent form
275: * submissions because the HTML is present.</p>
276: */
277: public boolean isVisible() {
278: if (this .visible_set) {
279: return this .visible;
280: }
281: ValueBinding _vb = getValueBinding("visible");
282: if (_vb != null) {
283: Object _result = _vb.getValue(getFacesContext());
284: if (_result == null) {
285: return false;
286: } else {
287: return ((Boolean) _result).booleanValue();
288: }
289: }
290: return true;
291: }
292:
293: /**
294: * <p>Use the visible attribute to indicate whether the component should be
295: * viewable by the user in the rendered HTML page. If set to false, the
296: * HTML code for the component is present in the page, but the component
297: * is hidden with style attributes. By default, visible is set to true, so
298: * HTML for the component HTML is included and visible to the user. If the
299: * component is not visible, it can still be processed on subsequent form
300: * submissions because the HTML is present.</p>
301: * @see #isVisible()
302: */
303: public void setVisible(boolean visible) {
304: this .visible = visible;
305: this .visible_set = true;
306: }
307:
308: /**
309: * <p>Restore the state of this component.</p>
310: */
311: public void restoreState(FacesContext _context, Object _state) {
312: Object _values[] = (Object[]) _state;
313: super .restoreState(_context, _values[0]);
314: this .showDetail = ((Boolean) _values[1]).booleanValue();
315: this .showDetail_set = ((Boolean) _values[2]).booleanValue();
316: this .showGlobalOnly = ((Boolean) _values[3]).booleanValue();
317: this .showGlobalOnly_set = ((Boolean) _values[4]).booleanValue();
318: this .showSummary = ((Boolean) _values[5]).booleanValue();
319: this .showSummary_set = ((Boolean) _values[6]).booleanValue();
320: this .style = (String) _values[7];
321: this .styleClass = (String) _values[8];
322: this .toolTip = (String) _values[9];
323: this .visible = ((Boolean) _values[10]).booleanValue();
324: this .visible_set = ((Boolean) _values[11]).booleanValue();
325: }
326:
327: /**
328: * <p>Save the state of this component.</p>
329: */
330: public Object saveState(FacesContext _context) {
331: Object _values[] = new Object[12];
332: _values[0] = super .saveState(_context);
333: _values[1] = this .showDetail ? Boolean.TRUE : Boolean.FALSE;
334: _values[2] = this .showDetail_set ? Boolean.TRUE : Boolean.FALSE;
335: _values[3] = this .showGlobalOnly ? Boolean.TRUE : Boolean.FALSE;
336: _values[4] = this .showGlobalOnly_set ? Boolean.TRUE
337: : Boolean.FALSE;
338: _values[5] = this .showSummary ? Boolean.TRUE : Boolean.FALSE;
339: _values[6] = this .showSummary_set ? Boolean.TRUE
340: : Boolean.FALSE;
341: _values[7] = this .style;
342: _values[8] = this .styleClass;
343: _values[9] = this .toolTip;
344: _values[10] = this .visible ? Boolean.TRUE : Boolean.FALSE;
345: _values[11] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
346: return _values;
347: }
348:
349: }
|