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(51, 51, 255);"><span
051: * style="color: rgb(0, 0, 0);">Use the </span><code
052: * style="color: rgb(0, 0, 0);">ui:staticText</code><span
053: * style="color: rgb(0, 0, 0);">
054: * tag to display text that is not interactive in the rendered HTML
055: * page. The text can be plain static text, or be formatted using
056: * parameters to insert variable text in the rendered HTML. The JSF core
057: * tag </span><code style="color: rgb(0, 0, 0);">f:param</code><span
058: * style="color: rgb(0, 0, 0);"> can be used along with view beans to
059: * provide
060: * the variable data.</span><br>
061: * </span></p>
062: * <p><code></code>If there are one or more
063: * params, the component will convert the list of parameter values to an <code>Object</code>
064: * array, and call <code>MessageFormat.format()</code>, passing the value
065: * of the param
066: * of this component as the first argument, the value of the
067: * array of parameter
068: * values as the second argument, and render the result. See <code>MessageFormat.format()</code>for
069: * details.<code> </code>Otherwise, render
070: * the text of
071: * this component unmodified.</p>
072: * <span style="color: rgb(255, 153, 0);"></span>
073: * <h3>HTML Elements and Layout</h3>
074: * <span style="color: rgb(0, 0, 0);">The rendered HTML page includes
075: * a </span><code style="color: rgb(0, 0, 0);"><span></code><span
076: * style="color: rgb(0, 0, 0);"> element that contains the resulting
077: * text. In the </span><code style="color: rgb(0, 0, 0);"><span></code><span
078: * style="color: rgb(0, 0, 0);"> element, the class and style
079: * attribute values are set to the values specified with the </span><code
080: * style="color: rgb(0, 0, 0);">ui:staticText</code><span
081: * style="color: rgb(0, 0, 0);"> tag's styleclass and style
082: * attributes.</span>
083: * <h3>Client Side Javascript Functions</h3>
084: * None.
085: * <br>
086: * <h3>Examples</h3>
087: * <h4>Example 1: Render plain old text<br>
088: * </h4>
089: * <div style="margin-left: 40px;"><code><ui:staticText
090: * id="statictext1" text="#{bean.someText}" /> </code><br>
091: * <code></code><code><ui:staticText id="statictext1" text="some text
092: * to display" /></code><code></code><br>
093: * <code></code></div>
094: * <h4>Example 2: Use Params to format a whole line<br>
095: * </h4>
096: * <code> <ui:staticText id="blah"
097: * text="At {1,time} on {1,date}, there was {2} on planet
098: * {0,number,integer}."><br>
099: * <f:param
100: * id="b1" value="#{HyperlinkBean.myInt}"/><br>
101: * <f:param
102: * id="b2" value="#{HyperlinkBean.date}"/><br>
103: * <f:param
104: * id="b3" value="2
105: * fools"/>
106: * <br>
107: * </ui:staticText><br>
108: * <br>
109: * </code>The above will render: <span id="form1:blah">"At 8:36:18
110: * AM on Dec 13, 2004, there was 2 fools on planet 7." <br>
111: * </span>
112: * <p>Auto-generated component class.
113: * Do <strong>NOT</strong> modify; all changes
114: * <strong>will</strong> be lost!</p>
115: */
116:
117: public abstract class StaticTextBase extends
118: javax.faces.component.UIOutput {
119:
120: /**
121: * <p>Construct a new <code>StaticTextBase</code>.</p>
122: */
123: public StaticTextBase() {
124: super ();
125: setRendererType("com.sun.rave.web.ui.StaticText");
126: }
127:
128: /**
129: * <p>Return the identifier of the component family to which this
130: * component belongs. This identifier, in conjunction with the value
131: * of the <code>rendererType</code> property, may be used to select
132: * the appropriate {@link Renderer} for this component instance.</p>
133: */
134: public String getFamily() {
135: return "com.sun.rave.web.ui.StaticText";
136: }
137:
138: /**
139: * <p>Return the <code>ValueBinding</code> stored for the
140: * specified name (if any), respecting any property aliases.</p>
141: *
142: * @param name Name of value binding to retrieve
143: */
144: public ValueBinding getValueBinding(String name) {
145: if (name.equals("text")) {
146: return super .getValueBinding("value");
147: }
148: return super .getValueBinding(name);
149: }
150:
151: /**
152: * <p>Set the <code>ValueBinding</code> stored for the
153: * specified name (if any), respecting any property
154: * aliases.</p>
155: *
156: * @param name Name of value binding to set
157: * @param binding ValueBinding to set, or null to remove
158: */
159: public void setValueBinding(String name, ValueBinding binding) {
160: if (name.equals("text")) {
161: super .setValueBinding("value", binding);
162: return;
163: }
164: super .setValueBinding(name, binding);
165: }
166:
167: // escape
168: private boolean escape = false;
169: private boolean escape_set = false;
170:
171: /**
172: * <p>Escape the text so it won't be interpreted by the browser as HTML markup</p>
173: */
174: public boolean isEscape() {
175: if (this .escape_set) {
176: return this .escape;
177: }
178: ValueBinding _vb = getValueBinding("escape");
179: if (_vb != null) {
180: Object _result = _vb.getValue(getFacesContext());
181: if (_result == null) {
182: return false;
183: } else {
184: return ((Boolean) _result).booleanValue();
185: }
186: }
187: return true;
188: }
189:
190: /**
191: * <p>Escape the text so it won't be interpreted by the browser as HTML markup</p>
192: * @see #isEscape()
193: */
194: public void setEscape(boolean escape) {
195: this .escape = escape;
196: this .escape_set = true;
197: }
198:
199: // onClick
200: private String onClick = null;
201:
202: /**
203: * <p>Scripting code executed when a mouse click
204: * occurs over this component.</p>
205: */
206: public String getOnClick() {
207: if (this .onClick != null) {
208: return this .onClick;
209: }
210: ValueBinding _vb = getValueBinding("onClick");
211: if (_vb != null) {
212: return (String) _vb.getValue(getFacesContext());
213: }
214: return null;
215: }
216:
217: /**
218: * <p>Scripting code executed when a mouse click
219: * occurs over this component.</p>
220: * @see #getOnClick()
221: */
222: public void setOnClick(String onClick) {
223: this .onClick = onClick;
224: }
225:
226: // onDblClick
227: private String onDblClick = null;
228:
229: /**
230: * <p>Scripting code executed when a mouse double click
231: * occurs over this component.</p>
232: */
233: public String getOnDblClick() {
234: if (this .onDblClick != null) {
235: return this .onDblClick;
236: }
237: ValueBinding _vb = getValueBinding("onDblClick");
238: if (_vb != null) {
239: return (String) _vb.getValue(getFacesContext());
240: }
241: return null;
242: }
243:
244: /**
245: * <p>Scripting code executed when a mouse double click
246: * occurs over this component.</p>
247: * @see #getOnDblClick()
248: */
249: public void setOnDblClick(String onDblClick) {
250: this .onDblClick = onDblClick;
251: }
252:
253: // onMouseDown
254: private String onMouseDown = null;
255:
256: /**
257: * <p>Scripting code executed when the user presses a mouse button while the
258: * mouse pointer is on the component.</p>
259: */
260: public String getOnMouseDown() {
261: if (this .onMouseDown != null) {
262: return this .onMouseDown;
263: }
264: ValueBinding _vb = getValueBinding("onMouseDown");
265: if (_vb != null) {
266: return (String) _vb.getValue(getFacesContext());
267: }
268: return null;
269: }
270:
271: /**
272: * <p>Scripting code executed when the user presses a mouse button while the
273: * mouse pointer is on the component.</p>
274: * @see #getOnMouseDown()
275: */
276: public void setOnMouseDown(String onMouseDown) {
277: this .onMouseDown = onMouseDown;
278: }
279:
280: // onMouseMove
281: private String onMouseMove = null;
282:
283: /**
284: * <p>Scripting code executed when the user moves the mouse pointer while
285: * over the component.</p>
286: */
287: public String getOnMouseMove() {
288: if (this .onMouseMove != null) {
289: return this .onMouseMove;
290: }
291: ValueBinding _vb = getValueBinding("onMouseMove");
292: if (_vb != null) {
293: return (String) _vb.getValue(getFacesContext());
294: }
295: return null;
296: }
297:
298: /**
299: * <p>Scripting code executed when the user moves the mouse pointer while
300: * over the component.</p>
301: * @see #getOnMouseMove()
302: */
303: public void setOnMouseMove(String onMouseMove) {
304: this .onMouseMove = onMouseMove;
305: }
306:
307: // onMouseOut
308: private String onMouseOut = null;
309:
310: /**
311: * <p>Scripting code executed when a mouse out movement
312: * occurs over this component.</p>
313: */
314: public String getOnMouseOut() {
315: if (this .onMouseOut != null) {
316: return this .onMouseOut;
317: }
318: ValueBinding _vb = getValueBinding("onMouseOut");
319: if (_vb != null) {
320: return (String) _vb.getValue(getFacesContext());
321: }
322: return null;
323: }
324:
325: /**
326: * <p>Scripting code executed when a mouse out movement
327: * occurs over this component.</p>
328: * @see #getOnMouseOut()
329: */
330: public void setOnMouseOut(String onMouseOut) {
331: this .onMouseOut = onMouseOut;
332: }
333:
334: // onMouseOver
335: private String onMouseOver = null;
336:
337: /**
338: * <p>Scripting code executed when the user moves the mouse pointer into
339: * the boundary of this component.</p>
340: */
341: public String getOnMouseOver() {
342: if (this .onMouseOver != null) {
343: return this .onMouseOver;
344: }
345: ValueBinding _vb = getValueBinding("onMouseOver");
346: if (_vb != null) {
347: return (String) _vb.getValue(getFacesContext());
348: }
349: return null;
350: }
351:
352: /**
353: * <p>Scripting code executed when the user moves the mouse pointer into
354: * the boundary of this component.</p>
355: * @see #getOnMouseOver()
356: */
357: public void setOnMouseOver(String onMouseOver) {
358: this .onMouseOver = onMouseOver;
359: }
360:
361: // onMouseUp
362: private String onMouseUp = null;
363:
364: /**
365: * <p>Scripting code executed when the user releases a mouse button while
366: * the mouse pointer is on the component.</p>
367: */
368: public String getOnMouseUp() {
369: if (this .onMouseUp != null) {
370: return this .onMouseUp;
371: }
372: ValueBinding _vb = getValueBinding("onMouseUp");
373: if (_vb != null) {
374: return (String) _vb.getValue(getFacesContext());
375: }
376: return null;
377: }
378:
379: /**
380: * <p>Scripting code executed when the user releases a mouse button while
381: * the mouse pointer is on the component.</p>
382: * @see #getOnMouseUp()
383: */
384: public void setOnMouseUp(String onMouseUp) {
385: this .onMouseUp = onMouseUp;
386: }
387:
388: // style
389: private String style = null;
390:
391: /**
392: * <p>CSS style(s) to be applied when this component is rendered.</p>
393: */
394: public String getStyle() {
395: if (this .style != null) {
396: return this .style;
397: }
398: ValueBinding _vb = getValueBinding("style");
399: if (_vb != null) {
400: return (String) _vb.getValue(getFacesContext());
401: }
402: return null;
403: }
404:
405: /**
406: * <p>CSS style(s) to be applied when this component is rendered.</p>
407: * @see #getStyle()
408: */
409: public void setStyle(String style) {
410: this .style = style;
411: }
412:
413: // styleClass
414: private String styleClass = null;
415:
416: /**
417: * <p>CSS style class(es) to be applied when this component is rendered.</p>
418: */
419: public String getStyleClass() {
420: if (this .styleClass != null) {
421: return this .styleClass;
422: }
423: ValueBinding _vb = getValueBinding("styleClass");
424: if (_vb != null) {
425: return (String) _vb.getValue(getFacesContext());
426: }
427: return null;
428: }
429:
430: /**
431: * <p>CSS style class(es) to be applied when this component is rendered.</p>
432: * @see #getStyleClass()
433: */
434: public void setStyleClass(String styleClass) {
435: this .styleClass = styleClass;
436: }
437:
438: // text
439: /**
440: * <p>The text value of this component</p>
441: */
442: public Object getText() {
443: return getValue();
444: }
445:
446: /**
447: * <p>The text value of this component</p>
448: * @see #getText()
449: */
450: public void setText(Object text) {
451: setValue(text);
452: }
453:
454: // toolTip
455: private String toolTip = null;
456:
457: /**
458: * <p>Display the text as a tooltip for this component</p>
459: */
460: public String getToolTip() {
461: if (this .toolTip != null) {
462: return this .toolTip;
463: }
464: ValueBinding _vb = getValueBinding("toolTip");
465: if (_vb != null) {
466: return (String) _vb.getValue(getFacesContext());
467: }
468: return null;
469: }
470:
471: /**
472: * <p>Display the text as a tooltip for this component</p>
473: * @see #getToolTip()
474: */
475: public void setToolTip(String toolTip) {
476: this .toolTip = toolTip;
477: }
478:
479: // visible
480: private boolean visible = false;
481: private boolean visible_set = false;
482:
483: /**
484: * <p>Use the visible attribute to indicate whether the component should be
485: * viewable by the user in the rendered HTML page. If set to false, the
486: * HTML code for the component is present in the page, but the component
487: * is hidden with style attributes. By default, visible is set to true, so
488: * HTML for the component HTML is included and visible to the user. If the
489: * component is not visible, it can still be processed on subsequent form
490: * submissions because the HTML is present.</p>
491: */
492: public boolean isVisible() {
493: if (this .visible_set) {
494: return this .visible;
495: }
496: ValueBinding _vb = getValueBinding("visible");
497: if (_vb != null) {
498: Object _result = _vb.getValue(getFacesContext());
499: if (_result == null) {
500: return false;
501: } else {
502: return ((Boolean) _result).booleanValue();
503: }
504: }
505: return true;
506: }
507:
508: /**
509: * <p>Use the visible attribute to indicate whether the component should be
510: * viewable by the user in the rendered HTML page. If set to false, the
511: * HTML code for the component is present in the page, but the component
512: * is hidden with style attributes. By default, visible is set to true, so
513: * HTML for the component HTML is included and visible to the user. If the
514: * component is not visible, it can still be processed on subsequent form
515: * submissions because the HTML is present.</p>
516: * @see #isVisible()
517: */
518: public void setVisible(boolean visible) {
519: this .visible = visible;
520: this .visible_set = true;
521: }
522:
523: /**
524: * <p>Restore the state of this component.</p>
525: */
526: public void restoreState(FacesContext _context, Object _state) {
527: Object _values[] = (Object[]) _state;
528: super .restoreState(_context, _values[0]);
529: this .escape = ((Boolean) _values[1]).booleanValue();
530: this .escape_set = ((Boolean) _values[2]).booleanValue();
531: this .onClick = (String) _values[3];
532: this .onDblClick = (String) _values[4];
533: this .onMouseDown = (String) _values[5];
534: this .onMouseMove = (String) _values[6];
535: this .onMouseOut = (String) _values[7];
536: this .onMouseOver = (String) _values[8];
537: this .onMouseUp = (String) _values[9];
538: this .style = (String) _values[10];
539: this .styleClass = (String) _values[11];
540: this .toolTip = (String) _values[12];
541: this .visible = ((Boolean) _values[13]).booleanValue();
542: this .visible_set = ((Boolean) _values[14]).booleanValue();
543: }
544:
545: /**
546: * <p>Save the state of this component.</p>
547: */
548: public Object saveState(FacesContext _context) {
549: Object _values[] = new Object[15];
550: _values[0] = super .saveState(_context);
551: _values[1] = this .escape ? Boolean.TRUE : Boolean.FALSE;
552: _values[2] = this .escape_set ? Boolean.TRUE : Boolean.FALSE;
553: _values[3] = this .onClick;
554: _values[4] = this .onDblClick;
555: _values[5] = this .onMouseDown;
556: _values[6] = this .onMouseMove;
557: _values[7] = this .onMouseOut;
558: _values[8] = this .onMouseOver;
559: _values[9] = this .onMouseUp;
560: _values[10] = this .style;
561: _values[11] = this .styleClass;
562: _values[12] = this .toolTip;
563: _values[13] = this .visible ? Boolean.TRUE : Boolean.FALSE;
564: _values[14] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
565: return _values;
566: }
567:
568: }
|