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