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: * <span style="color: rgb(0, 0, 0);">Use
051: * the <code>ui:pageAlert</code>
052: * tag to display a full page alert. A page alert differs from the
053: * inline alert (see </span><a
054: * href="file:///Users/smorgan/syncdocs/ui/alert.html"
055: * style="color: rgb(0, 0, 0);">ui:alert</a><span
056: * style="color: rgb(0, 0, 0);">) in that the content of
057: * the page
058: * that invokes the pageAlert is replaced by the alert page. An inline
059: * alert is a smaller alert that is inserted in the page that invokes the
060: * alert. </span><br
061: * style="color: rgb(0, 0, 0);">
062: * <h3 style="color: rgb(0, 0, 0);">HTML
063: * Elements and Layout</h3>
064: * <span style="color: rgb(0, 0, 0);">A
065: * page alert consists of:
066: * </span>
067: * <ul style="color: rgb(0, 0, 0);">
068: * <li><span
069: * style="text-decoration: line-through; font-weight: bold;"></span>an
070: * icon depicting the type of alert - question, information,
071: * warning, or error</li>
072: * <li>a page title next to the icon</li>
073: * <li>a summary message</li>
074: * <li>a detailed message</li>
075: * <li>one input component - (one text
076: * field, one text area, one checkbox,
077: * one set of radio buttons, one drop-down menu, or one scrolling list)</li>
078: * <li>a page separator line<br>
079: * </li>
080: * <li>a set of page level buttons</li>
081: * </ul>
082: * <p style="color: rgb(0, 0, 0);"><br>
083: * <span style="color: rgb(0, 0, 0);">The input field and the set of
084: * buttons are optional items, which must be specified with facets. </span><br>
085: * </p>
086: * <p style="color: rgb(0, 0, 0);">The
087: * following diagram shows
088: * the locations of each of the page alert areas, and the facets that are
089: * supported for specified areas.</p>
090: * <table style="color: rgb(0, 0, 0);"
091: * border="1" width="100%">
092: * <tbody>
093: * <tr>
094: * <td width="100%">Alert
095: * Icon (or optional <code>pageAlertImage</code> facet), Page Title Text (or
096: * optional <code>pageAlertTitle</code> facet)</td>
097: * </tr>
098: * <tr>
099: * <td colspan="2" width="100%">Alert
100: * summary<span
101: * style="text-decoration: line-through;"></span></td>
102: * </tr>
103: * <tr>
104: * <td style="vertical-align: top;">Detailed
105: * message<br>
106: * </td>
107: * </tr>
108: * <tr>
109: * <td colspan="2" width="100%">Optional
110: * <code>pageAlertInput</code>
111: * facet<br>
112: * </td>
113: * </tr>
114: * <tr>
115: * <td style="vertical-align: top;">Page separator (or optional
116: * <code>pageAlertSeparator</code>
117: * facet)<br>
118: * </td>
119: * </tr>
120: * <tr>
121: * <td colspan="2" align="right"
122: * width="100%">Optional <code>pageAlertButtons </code>facet</td>
123: * </tr>
124: * </tbody>
125: * </table>
126: * <p style="color: rgb(0, 0, 0);"> </p>
127: * <h3 style="color: rgb(0, 0, 0);">Facets</h3>
128: * <span style="color: rgb(0, 0, 0);">The
129: * <code>ui:pageAlert</code>
130: * tag supports the following facets.</span><br>
131: * <br>
132: * <table style="text-align: left; width: 100%;"
133: * border="1" cellpadding="2" cellspacing="2">
134: * <tbody>
135: * <tr>
136: * <td style="vertical-align: top;"><code
137: * style="color: rgb(0, 0, 0);">pageAlertTitle</code></td>
138: * <td
139: * style="vertical-align: top; color: rgb(0, 0, 0);">Specifies
140: * a custom component to use to display the title of the alert.<span
141: * style="color: rgb(255, 153, 0);"></span><br>
142: * </td>
143: * </tr>
144: * <tr>
145: * <td style="vertical-align: top;"><code
146: * style="color: rgb(0, 0, 0);">pageAlertInput</code></td>
147: * <td
148: * style="vertical-align: top; color: rgb(0, 0, 0);">Specifies
149: * a component to use in the body of the full page alert. This facet can be
150: * used to display an input component
151: * for the user to perform tasks related
152: * to the alert, for example.<br>
153: * </td>
154: * </tr>
155: * <tr>
156: * <td style="vertical-align: top;"><code
157: * style="color: rgb(0, 0, 0);">pageAlertButtons</code></td>
158: * <td
159: * style="vertical-align: top; color: rgb(0, 0, 0);">Specifies
160: * components to use for the buttons at the bottom of the alert page. This
161: * facet can be used to display a back button, for example. If you want to specify more than
162: * one button, you might find it helpful to enclose the button components
163: * in a <code>ui:panelGroup</code> component.<br>
164: * </td>
165: * </tr>
166: * <tr>
167: * <td
168: * style="vertical-align: top; color: rgb(0, 0, 0);"><code>pageAlertSeparator<br>
169: * </code></td>
170: * <td
171: * style="vertical-align: top; color: rgb(0, 0, 0);">Specifies
172: * a component to use for the page separator that is displayed above the
173: * page buttons. The component included in this facet replaces the default
174: * page separator.<br>
175: * </td>
176: * </tr>
177: * <tr>
178: * <td
179: * style="vertical-align: top; color: rgb(0, 0, 0);"><code>pageAlertImage<br>
180: * </code></td>
181: * <td
182: * style="vertical-align: top; color: rgb(0, 0, 0);">Specifies
183: * a component to use to display the alert icon. The component included
184: * in this facet replaces the default icon.<br>
185: * </td>
186: * </tr>
187: * </tbody>
188: * </table>
189: * <br>
190: * <h3>Client Side Javascript
191: * Functions</h3>
192: * None. <span style="color: rgb(255, 153, 0);"></span><br>
193: * <h3>Examples</h3>
194: * <h4><span
195: * style="color: rgb(0, 0, 0);">Example 1:</span>
196: * Simple example, with alert message and a back button.</h4>
197: * <code></code>
198: * <pre> <ui:pageAlert id="pagealert" title="Error!" type="error"<br> summary="Server Not Responding." <br> detail="The server jurassic is not responding. Verify that the power cable is connected."><br> <f:facet name="pageAlertButtons"><br> <ui:button text="Back" action="indexPage" /><br> </ui:pageAlert></pre>
199: * <h4><span style="color: rgb(255, 153, 0);"></span><span
200: * style="color: rgb(0, 0, 0);">Example 2:</span>
201: * With
202: * input field and one page button.</h4><code></code>
203: * <pre> <ui:pageAlert id="pagealert" title="Password Expired!" type="warning"<br> summary="Password expired." <br> detail="Your password has expired. Enter a new password"><br> <f:facet name="pageAlertButtons"><br> <ui:button text="Go to Login Page" action="success" /> <br> </f:facet><br> <f:facet name="pageAlertInput"><br> <ui:panelGroup id="pageAlertStuff"><br> <ui:label text="New Password:" for="passwordField"/><br> <ui:field id="passwordField" type="password"/><br> </ui:panelGroup><br> </f:facet> <br> </ui:pageAlert><br></pre>
204: * <p>Auto-generated component class.
205: * Do <strong>NOT</strong> modify; all changes
206: * <strong>will</strong> be lost!</p>
207: */
208:
209: public abstract class PageAlertBase extends
210: javax.faces.component.UIComponentBase {
211:
212: /**
213: * <p>Construct a new <code>PageAlertBase</code>.</p>
214: */
215: public PageAlertBase() {
216: super ();
217: setRendererType("com.sun.rave.web.ui.PageAlert");
218: }
219:
220: /**
221: * <p>Return the identifier of the component family to which this
222: * component belongs. This identifier, in conjunction with the value
223: * of the <code>rendererType</code> property, may be used to select
224: * the appropriate {@link Renderer} for this component instance.</p>
225: */
226: public String getFamily() {
227: return "com.sun.rave.web.ui.PageAlert";
228: }
229:
230: // alt
231: private String alt = null;
232:
233: /**
234: * <p>Alternative text description used by screen reader tools</p>
235: */
236: public String getAlt() {
237: if (this .alt != null) {
238: return this .alt;
239: }
240: ValueBinding _vb = getValueBinding("alt");
241: if (_vb != null) {
242: return (String) _vb.getValue(getFacesContext());
243: }
244: return null;
245: }
246:
247: /**
248: * <p>Alternative text description used by screen reader tools</p>
249: * @see #getAlt()
250: */
251: public void setAlt(String alt) {
252: this .alt = alt;
253: }
254:
255: // detail
256: private String detail = null;
257:
258: /**
259: * <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>
260: */
261: public String getDetail() {
262: if (this .detail != null) {
263: return this .detail;
264: }
265: ValueBinding _vb = getValueBinding("detail");
266: if (_vb != null) {
267: return (String) _vb.getValue(getFacesContext());
268: }
269: return null;
270: }
271:
272: /**
273: * <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>
274: * @see #getDetail()
275: */
276: public void setDetail(String detail) {
277: this .detail = detail;
278: }
279:
280: // escape
281: private boolean escape = false;
282: private boolean escape_set = false;
283:
284: /**
285: * <p>Flag indicating that the message text should be escaped so that it is
286: * not interpreted by the browser.</p>
287: */
288: public boolean isEscape() {
289: if (this .escape_set) {
290: return this .escape;
291: }
292: ValueBinding _vb = getValueBinding("escape");
293: if (_vb != null) {
294: Object _result = _vb.getValue(getFacesContext());
295: if (_result == null) {
296: return false;
297: } else {
298: return ((Boolean) _result).booleanValue();
299: }
300: }
301: return true;
302: }
303:
304: /**
305: * <p>Flag indicating that the message text should be escaped so that it is
306: * not interpreted by the browser.</p>
307: * @see #isEscape()
308: */
309: public void setEscape(boolean escape) {
310: this .escape = escape;
311: this .escape_set = true;
312: }
313:
314: // style
315: private String style = null;
316:
317: /**
318: * <p>CSS style(s) to be applied when this component is rendered.</p>
319: */
320: public String getStyle() {
321: if (this .style != null) {
322: return this .style;
323: }
324: ValueBinding _vb = getValueBinding("style");
325: if (_vb != null) {
326: return (String) _vb.getValue(getFacesContext());
327: }
328: return null;
329: }
330:
331: /**
332: * <p>CSS style(s) to be applied when this component is rendered.</p>
333: * @see #getStyle()
334: */
335: public void setStyle(String style) {
336: this .style = style;
337: }
338:
339: // styleClass
340: private String styleClass = null;
341:
342: /**
343: * <p>CSS style class(es) to be applied when this component is rendered.</p>
344: */
345: public String getStyleClass() {
346: if (this .styleClass != null) {
347: return this .styleClass;
348: }
349: ValueBinding _vb = getValueBinding("styleClass");
350: if (_vb != null) {
351: return (String) _vb.getValue(getFacesContext());
352: }
353: return null;
354: }
355:
356: /**
357: * <p>CSS style class(es) to be applied when this component is rendered.</p>
358: * @see #getStyleClass()
359: */
360: public void setStyleClass(String styleClass) {
361: this .styleClass = styleClass;
362: }
363:
364: // summary
365: private String summary = null;
366:
367: /**
368: * <p>Summary message text for the alert. This brief message is displayed under the page alert title.</p>
369: */
370: public String getSummary() {
371: if (this .summary != null) {
372: return this .summary;
373: }
374: ValueBinding _vb = getValueBinding("summary");
375: if (_vb != null) {
376: return (String) _vb.getValue(getFacesContext());
377: }
378: return null;
379: }
380:
381: /**
382: * <p>Summary message text for the alert. This brief message is displayed under the page alert title.</p>
383: * @see #getSummary()
384: */
385: public void setSummary(String summary) {
386: this .summary = summary;
387: }
388:
389: // tabIndex
390: private int tabIndex = Integer.MIN_VALUE;
391: private boolean tabIndex_set = false;
392:
393: /**
394: * <p>The position of this component in the tabbing order sequence</p>
395: */
396: public int getTabIndex() {
397: if (this .tabIndex_set) {
398: return this .tabIndex;
399: }
400: ValueBinding _vb = getValueBinding("tabIndex");
401: if (_vb != null) {
402: Object _result = _vb.getValue(getFacesContext());
403: if (_result == null) {
404: return Integer.MIN_VALUE;
405: } else {
406: return ((Integer) _result).intValue();
407: }
408: }
409: return Integer.MIN_VALUE;
410: }
411:
412: /**
413: * <p>The position of this component in the tabbing order sequence</p>
414: * @see #getTabIndex()
415: */
416: public void setTabIndex(int tabIndex) {
417: this .tabIndex = tabIndex;
418: this .tabIndex_set = true;
419: }
420:
421: // title
422: private String title = null;
423:
424: /**
425: * <p>The text to display as the page title</p>
426: */
427: public String getTitle() {
428: if (this .title != null) {
429: return this .title;
430: }
431: ValueBinding _vb = getValueBinding("title");
432: if (_vb != null) {
433: return (String) _vb.getValue(getFacesContext());
434: }
435: return null;
436: }
437:
438: /**
439: * <p>The text to display as the page title</p>
440: * @see #getTitle()
441: */
442: public void setTitle(String title) {
443: this .title = title;
444: }
445:
446: // type
447: private String type = null;
448:
449: /**
450: * <p>The type or category of alert. The type attribute can be set to one of the following: "question", "information", "warning" or "error". The default type is error.</p>
451: */
452: public String getType() {
453: if (this .type != null) {
454: return this .type;
455: }
456: ValueBinding _vb = getValueBinding("type");
457: if (_vb != null) {
458: return (String) _vb.getValue(getFacesContext());
459: }
460: return "error";
461: }
462:
463: /**
464: * <p>The type or category of alert. The type attribute can be set to one of the following: "question", "information", "warning" or "error". The default type is error.</p>
465: * @see #getType()
466: */
467: public void setType(String type) {
468: this .type = type;
469: }
470:
471: // visible
472: private boolean visible = false;
473: private boolean visible_set = false;
474:
475: /**
476: * <p>Use the visible attribute to indicate whether the component should be
477: * viewable by the user in the rendered HTML page. If set to false, the
478: * HTML code for the component is present in the page, but the component
479: * is hidden with style attributes. By default, visible is set to true, so
480: * HTML for the component HTML is included and visible to the user. If the
481: * component is not visible, it can still be processed on subsequent form
482: * submissions because the HTML is present.</p>
483: */
484: public boolean isVisible() {
485: if (this .visible_set) {
486: return this .visible;
487: }
488: ValueBinding _vb = getValueBinding("visible");
489: if (_vb != null) {
490: Object _result = _vb.getValue(getFacesContext());
491: if (_result == null) {
492: return false;
493: } else {
494: return ((Boolean) _result).booleanValue();
495: }
496: }
497: return true;
498: }
499:
500: /**
501: * <p>Use the visible attribute to indicate whether the component should be
502: * viewable by the user in the rendered HTML page. If set to false, the
503: * HTML code for the component is present in the page, but the component
504: * is hidden with style attributes. By default, visible is set to true, so
505: * HTML for the component HTML is included and visible to the user. If the
506: * component is not visible, it can still be processed on subsequent form
507: * submissions because the HTML is present.</p>
508: * @see #isVisible()
509: */
510: public void setVisible(boolean visible) {
511: this .visible = visible;
512: this .visible_set = true;
513: }
514:
515: /**
516: * <p>Restore the state of this component.</p>
517: */
518: public void restoreState(FacesContext _context, Object _state) {
519: Object _values[] = (Object[]) _state;
520: super .restoreState(_context, _values[0]);
521: this .alt = (String) _values[1];
522: this .detail = (String) _values[2];
523: this .escape = ((Boolean) _values[3]).booleanValue();
524: this .escape_set = ((Boolean) _values[4]).booleanValue();
525: this .style = (String) _values[5];
526: this .styleClass = (String) _values[6];
527: this .summary = (String) _values[7];
528: this .tabIndex = ((Integer) _values[8]).intValue();
529: this .tabIndex_set = ((Boolean) _values[9]).booleanValue();
530: this .title = (String) _values[10];
531: this .type = (String) _values[11];
532: this .visible = ((Boolean) _values[12]).booleanValue();
533: this .visible_set = ((Boolean) _values[13]).booleanValue();
534: }
535:
536: /**
537: * <p>Save the state of this component.</p>
538: */
539: public Object saveState(FacesContext _context) {
540: Object _values[] = new Object[14];
541: _values[0] = super .saveState(_context);
542: _values[1] = this .alt;
543: _values[2] = this .detail;
544: _values[3] = this .escape ? Boolean.TRUE : Boolean.FALSE;
545: _values[4] = this .escape_set ? Boolean.TRUE : Boolean.FALSE;
546: _values[5] = this .style;
547: _values[6] = this .styleClass;
548: _values[7] = this .summary;
549: _values[8] = new Integer(this .tabIndex);
550: _values[9] = this .tabIndex_set ? Boolean.TRUE : Boolean.FALSE;
551: _values[10] = this .title;
552: _values[11] = this .type;
553: _values[12] = this .visible ? Boolean.TRUE : Boolean.FALSE;
554: _values[13] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
555: return _values;
556: }
557:
558: }
|