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:alert</code>
051: * tag to display an inline alert
052: * message at the top of the rendered HTML page. Inline alert messages
053: * permit users to correct problems or proceed with their work without
054: * having to dismiss a window and navigate to a new location.
055: * There 2 facets associated with an alert tag: <br>
056: * alertImage - allows the developer to put
057: * in their own image and/or text<br>
058: * alertLink - allows the developer to put
059: * in their own formatted link or extra text.<br>
060: * <h3>HTML Elements and Layout</h3>
061: * An alert message consists of an icon depicting the type of alert -
062: * information, success, warning, or error - along with a <code>summary</code>
063: * message and an optional <code>detail</code>
064: * message.
065: * <h3>Client Side Javascript
066: * Functions</h3>
067: * none.
068: * <h3>Examples</h3>
069: * <b>Example 1: An example showing
070: * an informational alert:</b> <br>
071: * <code><ui:alert id="msg1"
072: * type="information" summary="Patch Installed Successfully" detail="Patch
073: * 9997-01 was successfully installed on host alpha, beta and zed."
074: * /><br>
075: * </code>
076: * <br>
077: * <b>Example 2: An example showing
078: * an error alert with an alert link:</b><br>
079: * <code><ui:alert id="msg2"
080: * type="error" summary="Patch Installation Failed!"
081: * detail="Patch 9997-01 was not installed on host alpha, beta and zed."
082: * linkText="View Log" linkURL="/log/patch-log.txt" linkTarget="_blank"
083: * linkToolTip="Open Window Containing Error Log"/><br>
084: * <br>
085: * </code><b>Example
086: * 3: An example showing the use of an alertImage facet:</b><br>
087: * <code><ui:alert id="msg2"
088: * type="error" summary="Patch Installation Failed!"
089: * detail="Patch 9997-01 was not installed on host alpha, beta and
090: * zed."><br>
091: * <f:facet name="alertImage"><br>
092: * <ui:image
093: * id="foo" </code><code>url="../images/foo.gif"
094: * /><br>
095: * </f:facet><br>
096: * </ui:alert><br>
097: * </code>
098: * <p>Auto-generated component class.
099: * Do <strong>NOT</strong> modify; all changes
100: * <strong>will</strong> be lost!</p>
101: */
102:
103: public abstract class AlertBase extends javax.faces.component.UIOutput {
104:
105: /**
106: * <p>Construct a new <code>AlertBase</code>.</p>
107: */
108: public AlertBase() {
109: super ();
110: setRendererType("com.sun.rave.web.ui.Alert");
111: }
112:
113: /**
114: * <p>Return the identifier of the component family to which this
115: * component belongs. This identifier, in conjunction with the value
116: * of the <code>rendererType</code> property, may be used to select
117: * the appropriate {@link Renderer} for this component instance.</p>
118: */
119: public String getFamily() {
120: return "com.sun.rave.web.ui.Alert";
121: }
122:
123: // alt
124: private String alt = null;
125:
126: /**
127: * <p>Alternative text description used by screen reader tools</p>
128: */
129: public String getAlt() {
130: if (this .alt != null) {
131: return this .alt;
132: }
133: ValueBinding _vb = getValueBinding("alt");
134: if (_vb != null) {
135: return (String) _vb.getValue(getFacesContext());
136: }
137: return null;
138: }
139:
140: /**
141: * <p>Alternative text description used by screen reader tools</p>
142: * @see #getAlt()
143: */
144: public void setAlt(String alt) {
145: this .alt = alt;
146: }
147:
148: // detail
149: private String detail = null;
150:
151: /**
152: * <p>Optional detailed message text for the alert. This message might include more information about the alert and instructions for what to do about the alert.</p>
153: */
154: public String getDetail() {
155: if (this .detail != null) {
156: return this .detail;
157: }
158: ValueBinding _vb = getValueBinding("detail");
159: if (_vb != null) {
160: return (String) _vb.getValue(getFacesContext());
161: }
162: return null;
163: }
164:
165: /**
166: * <p>Optional detailed message text for the alert. This message might include more information about the alert and instructions for what to do about the alert.</p>
167: * @see #getDetail()
168: */
169: public void setDetail(String detail) {
170: this .detail = detail;
171: }
172:
173: // linkAction
174: private javax.faces.el.MethodBinding linkAction = null;
175:
176: /**
177: * <p>Method binding representing a method that receives action from the
178: * embedded hyperlink component.</p>
179: */
180: public javax.faces.el.MethodBinding getLinkAction() {
181: if (this .linkAction != null) {
182: return this .linkAction;
183: }
184: ValueBinding _vb = getValueBinding("linkAction");
185: if (_vb != null) {
186: return (javax.faces.el.MethodBinding) _vb
187: .getValue(getFacesContext());
188: }
189: return null;
190: }
191:
192: /**
193: * <p>Method binding representing a method that receives action from the
194: * embedded hyperlink component.</p>
195: * @see #getLinkAction()
196: */
197: public void setLinkAction(javax.faces.el.MethodBinding linkAction) {
198: this .linkAction = linkAction;
199: }
200:
201: // linkTarget
202: private String linkTarget = null;
203:
204: /**
205: * <p>The window (target) in which to load the link that is specified with linkText.</p>
206: */
207: public String getLinkTarget() {
208: if (this .linkTarget != null) {
209: return this .linkTarget;
210: }
211: ValueBinding _vb = getValueBinding("linkTarget");
212: if (_vb != null) {
213: return (String) _vb.getValue(getFacesContext());
214: }
215: return null;
216: }
217:
218: /**
219: * <p>The window (target) in which to load the link that is specified with linkText.</p>
220: * @see #getLinkTarget()
221: */
222: public void setLinkTarget(String linkTarget) {
223: this .linkTarget = linkTarget;
224: }
225:
226: // linkText
227: private String linkText = null;
228:
229: /**
230: * <p>The text for an optional link that is appended to the detail message.</p>
231: */
232: public String getLinkText() {
233: if (this .linkText != null) {
234: return this .linkText;
235: }
236: ValueBinding _vb = getValueBinding("linkText");
237: if (_vb != null) {
238: return (String) _vb.getValue(getFacesContext());
239: }
240: return null;
241: }
242:
243: /**
244: * <p>The text for an optional link that is appended to the detail message.</p>
245: * @see #getLinkText()
246: */
247: public void setLinkText(String linkText) {
248: this .linkText = linkText;
249: }
250:
251: // linkToolTip
252: private String linkToolTip = null;
253:
254: /**
255: * <p>Sets the value of the title attribute for the HTML element. The specified text
256: * will display as a tooltip if the mouse cursor hovers over the link that is specified
257: * with linkText.</p>
258: */
259: public String getLinkToolTip() {
260: if (this .linkToolTip != null) {
261: return this .linkToolTip;
262: }
263: ValueBinding _vb = getValueBinding("linkToolTip");
264: if (_vb != null) {
265: return (String) _vb.getValue(getFacesContext());
266: }
267: return null;
268: }
269:
270: /**
271: * <p>Sets the value of the title attribute for the HTML element. The specified text
272: * will display as a tooltip if the mouse cursor hovers over the link that is specified
273: * with linkText.</p>
274: * @see #getLinkToolTip()
275: */
276: public void setLinkToolTip(String linkToolTip) {
277: this .linkToolTip = linkToolTip;
278: }
279:
280: // linkURL
281: private String linkURL = null;
282:
283: /**
284: * <p>Absolute, relative, or context relative (starting with "/") URL to the resource to navigate
285: * to when the link that is specified with linkText is selected.</p>
286: */
287: public String getLinkURL() {
288: if (this .linkURL != null) {
289: return this .linkURL;
290: }
291: ValueBinding _vb = getValueBinding("linkURL");
292: if (_vb != null) {
293: return (String) _vb.getValue(getFacesContext());
294: }
295: return null;
296: }
297:
298: /**
299: * <p>Absolute, relative, or context relative (starting with "/") URL to the resource to navigate
300: * to when the link that is specified with linkText is selected.</p>
301: * @see #getLinkURL()
302: */
303: public void setLinkURL(String linkURL) {
304: this .linkURL = linkURL;
305: }
306:
307: // style
308: private String style = null;
309:
310: /**
311: * <p>CSS style(s) to be applied when this component is rendered.</p>
312: */
313: public String getStyle() {
314: if (this .style != null) {
315: return this .style;
316: }
317: ValueBinding _vb = getValueBinding("style");
318: if (_vb != null) {
319: return (String) _vb.getValue(getFacesContext());
320: }
321: return null;
322: }
323:
324: /**
325: * <p>CSS style(s) to be applied when this component is rendered.</p>
326: * @see #getStyle()
327: */
328: public void setStyle(String style) {
329: this .style = style;
330: }
331:
332: // styleClass
333: private String styleClass = null;
334:
335: /**
336: * <p>CSS style class(es) to be applied when this component is rendered.</p>
337: */
338: public String getStyleClass() {
339: if (this .styleClass != null) {
340: return this .styleClass;
341: }
342: ValueBinding _vb = getValueBinding("styleClass");
343: if (_vb != null) {
344: return (String) _vb.getValue(getFacesContext());
345: }
346: return null;
347: }
348:
349: /**
350: * <p>CSS style class(es) to be applied when this component is rendered.</p>
351: * @see #getStyleClass()
352: */
353: public void setStyleClass(String styleClass) {
354: this .styleClass = styleClass;
355: }
356:
357: // summary
358: private String summary = null;
359:
360: /**
361: * <p>Summary message text for the alert. This brief message is prominently
362: * displayed next to the icon.</p>
363: */
364: public String getSummary() {
365: if (this .summary != null) {
366: return this .summary;
367: }
368: ValueBinding _vb = getValueBinding("summary");
369: if (_vb != null) {
370: return (String) _vb.getValue(getFacesContext());
371: }
372: return null;
373: }
374:
375: /**
376: * <p>Summary message text for the alert. This brief message is prominently
377: * displayed next to the icon.</p>
378: * @see #getSummary()
379: */
380: public void setSummary(String summary) {
381: this .summary = summary;
382: }
383:
384: // tabIndex
385: private int tabIndex = Integer.MIN_VALUE;
386: private boolean tabIndex_set = false;
387:
388: /**
389: * <p>The position of this component in the tabbing order sequence</p>
390: */
391: public int getTabIndex() {
392: if (this .tabIndex_set) {
393: return this .tabIndex;
394: }
395: ValueBinding _vb = getValueBinding("tabIndex");
396: if (_vb != null) {
397: Object _result = _vb.getValue(getFacesContext());
398: if (_result == null) {
399: return Integer.MIN_VALUE;
400: } else {
401: return ((Integer) _result).intValue();
402: }
403: }
404: return Integer.MIN_VALUE;
405: }
406:
407: /**
408: * <p>The position of this component in the tabbing order sequence</p>
409: * @see #getTabIndex()
410: */
411: public void setTabIndex(int tabIndex) {
412: this .tabIndex = tabIndex;
413: this .tabIndex_set = true;
414: }
415:
416: // type
417: private String type = null;
418:
419: /**
420: * <p>The type or category of alert. This type can be set to either "information", "success", "warning" or "error".</p>
421: */
422: public String getType() {
423: if (this .type != null) {
424: return this .type;
425: }
426: ValueBinding _vb = getValueBinding("type");
427: if (_vb != null) {
428: return (String) _vb.getValue(getFacesContext());
429: }
430: return null;
431: }
432:
433: /**
434: * <p>The type or category of alert. This type can be set to either "information", "success", "warning" or "error".</p>
435: * @see #getType()
436: */
437: public void setType(String type) {
438: this .type = type;
439: }
440:
441: // visible
442: private boolean visible = false;
443: private boolean visible_set = false;
444:
445: /**
446: * <p>Use the visible attribute to indicate whether the component should be
447: * viewable by the user in the rendered HTML page. If set to false, the
448: * HTML code for the component is present in the page, but the component
449: * is hidden with style attributes. By default, visible is set to true, so
450: * HTML for the component HTML is included and visible to the user. If the
451: * component is not visible, it can still be processed on subsequent form
452: * submissions because the HTML is present.</p>
453: */
454: public boolean isVisible() {
455: if (this .visible_set) {
456: return this .visible;
457: }
458: ValueBinding _vb = getValueBinding("visible");
459: if (_vb != null) {
460: Object _result = _vb.getValue(getFacesContext());
461: if (_result == null) {
462: return false;
463: } else {
464: return ((Boolean) _result).booleanValue();
465: }
466: }
467: return true;
468: }
469:
470: /**
471: * <p>Use the visible attribute to indicate whether the component should be
472: * viewable by the user in the rendered HTML page. If set to false, the
473: * HTML code for the component is present in the page, but the component
474: * is hidden with style attributes. By default, visible is set to true, so
475: * HTML for the component HTML is included and visible to the user. If the
476: * component is not visible, it can still be processed on subsequent form
477: * submissions because the HTML is present.</p>
478: * @see #isVisible()
479: */
480: public void setVisible(boolean visible) {
481: this .visible = visible;
482: this .visible_set = true;
483: }
484:
485: /**
486: * <p>Restore the state of this component.</p>
487: */
488: public void restoreState(FacesContext _context, Object _state) {
489: Object _values[] = (Object[]) _state;
490: super .restoreState(_context, _values[0]);
491: this .alt = (String) _values[1];
492: this .detail = (String) _values[2];
493: this .linkAction = (javax.faces.el.MethodBinding) restoreAttachedState(
494: _context, _values[3]);
495: this .linkTarget = (String) _values[4];
496: this .linkText = (String) _values[5];
497: this .linkToolTip = (String) _values[6];
498: this .linkURL = (String) _values[7];
499: this .style = (String) _values[8];
500: this .styleClass = (String) _values[9];
501: this .summary = (String) _values[10];
502: this .tabIndex = ((Integer) _values[11]).intValue();
503: this .tabIndex_set = ((Boolean) _values[12]).booleanValue();
504: this .type = (String) _values[13];
505: this .visible = ((Boolean) _values[14]).booleanValue();
506: this .visible_set = ((Boolean) _values[15]).booleanValue();
507: }
508:
509: /**
510: * <p>Save the state of this component.</p>
511: */
512: public Object saveState(FacesContext _context) {
513: Object _values[] = new Object[16];
514: _values[0] = super .saveState(_context);
515: _values[1] = this .alt;
516: _values[2] = this .detail;
517: _values[3] = saveAttachedState(_context, linkAction);
518: _values[4] = this .linkTarget;
519: _values[5] = this .linkText;
520: _values[6] = this .linkToolTip;
521: _values[7] = this .linkURL;
522: _values[8] = this .style;
523: _values[9] = this .styleClass;
524: _values[10] = this .summary;
525: _values[11] = new Integer(this .tabIndex);
526: _values[12] = this .tabIndex_set ? Boolean.TRUE : Boolean.FALSE;
527: _values[13] = this .type;
528: _values[14] = this .visible ? Boolean.TRUE : Boolean.FALSE;
529: _values[15] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
530: return _values;
531: }
532:
533: }
|