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:imageHyperlink</code><span
053: * style="color: rgb(0, 0, 0);">
054: * tag to display a clickable image in the rendered HTML page. The image
055: * is surrounded by an HTML hyperlink, allowing the image to function as a
056: * hyperlink. This tag is based on a <code>ui:hyperlink</code>
057: * tag and functions the same way. The main difference is this
058: * tag will format an image with a surrounding hyperlink. See
059: * the <code>ui:hyperlink</code>
060: * tag for more examples on using a hyperlink.</span></span><br>
061: * <br>
062: * The
063: * <span style="color: rgb(51, 51, 255);"><code
064: * style="color: rgb(0, 0, 0);">ui:imageHyperlink</code><span
065: * style="color: rgb(0, 0, 0);"></span></span>
066: * component
067: * can be also be used to submit forms. If the action attribute is used,
068: * the form is submitted. If the
069: * url attribute is used, the link is a normal hyperlink that sends the
070: * browser to a new location.<br>
071: * <br>
072: * <span style="color: rgb(0, 0, 0);">The
073: * <code>ui:imageHyperlink</code>
074: * can display a clickable icon image from the current theme in the
075: * rendered HTML page using the "icon" attribute. The <code></code>tag
076: * allows you to use an
077: * icon (a small image) from the current theme. Currently the list of
078: * icons that you can use is not publicly supported, but the icon names
079: * are specified in the <code>/com/sun/rave/web/ui/suntheme/SunTheme.properties</code>
080: * file. The names are listed as resource keys of the format <code>image.ICON_NAME.</code>
081: * Use only the part of the key that follows <code>image.
082: * </code>For
083: * example, if the key is <code>image.ALARM_CRITICAL_SMALL</code>,
084: * you
085: * should use <code>ALARM_CRITICAL_SMALL
086: * </code>as the specified
087: * icon name in the <code>ui:</code></span><span
088: * style="color: rgb(0, 0, 0);"><code>imageHyperlink</code>
089: * </span><span
090: * style="color: rgb(0, 0, 0);"><code></code>tag.
091: * In the near future a
092: * supported list will be published. </span><br>
093: * <span style="color: rgb(0, 0, 0);">
094: * <h3 style="color: rgb(0, 0, 0);">HTML
095: * Elements and Layout</h3>
096: * <span style="color: rgb(0, 0, 0);"></span>
097: * <p><span
098: * style="color: rgb(0, 0, 0);">The rendered HTML page
099: * contains
100: * an XHTML <code><a></code>
101: * element with an <code><img></code>
102: * element inside. <code></code>
103: * Image attributes that are specified
104: * with the <code>ui:imageHyperlink</code>
105: * tag are used as attributes in
106: * the <code><img></code>
107: * element.</span><br>
108: * </p>
109: * <h3 style="color: rgb(0, 0, 0);">Theme
110: * Identifiers</h3>
111: * <span style="color: rgb(0, 0, 0);">None</span><br>
112: * <h3>Client Side Javascript
113: * Functions<span
114: * style="color: rgb(255, 153, 0);"></span><br>
115: * </h3>
116: * <p>None. <span
117: * style="color: rgb(255, 153, 0);"></span></p>
118: * <h3>Examples <span
119: * style="color: rgb(255, 153, 0);"></span></h3>
120: * <span style="color: rgb(255, 153, 0);"></span>
121: * <h4>Example 1: Create an <span
122: * style="text-decoration: line-through;"></span><span
123: * style="color: rgb(0, 0, 0);">imageHyperlink</span>
124: * with yahoo gif<br>
125: * </h4>
126: * <span style="color: rgb(255, 153, 0);"></span><code><ui:imageHyperlink
127: * id="imagehyperlinktest1" imageURL="./myyahoo.gif"
128: * action="#{HyperlinkBean.getRequiredHelp}" /></code></span><span
129: * style="color: rgb(0, 0, 0);"><br>
130: * </span>
131: * <h4 style="color: rgb(0, 0, 0);">Example
132: * 2: Create an IconHyperlink using the required
133: * indicator icon<br>
134: * </h4>
135: * <span style="color: rgb(0, 0, 0);">
136: * </span><code
137: * style="color: rgb(0, 0, 0);"><ui:iconHyperlink
138: * id="iconhyperlinktest1" <br>
139: *
140: * icon="LABEL_REQUIRED_ICON"
141: * <br>
142: *
143: * action="#{HyperlinkBean.getRequiredHelp}" />
144: * </code><span
145: * style="color: rgb(0, 0, 0);"><br>
146: * </span>
147: * <p>Auto-generated component class.
148: * Do <strong>NOT</strong> modify; all changes
149: * <strong>will</strong> be lost!</p>
150: */
151:
152: public abstract class ImageHyperlinkBase extends
153: com.sun.rave.web.ui.component.Hyperlink {
154:
155: /**
156: * <p>Construct a new <code>ImageHyperlinkBase</code>.</p>
157: */
158: public ImageHyperlinkBase() {
159: super ();
160: setRendererType("com.sun.rave.web.ui.ImageHyperlink");
161: }
162:
163: /**
164: * <p>Return the identifier of the component family to which this
165: * component belongs. This identifier, in conjunction with the value
166: * of the <code>rendererType</code> property, may be used to select
167: * the appropriate {@link Renderer} for this component instance.</p>
168: */
169: public String getFamily() {
170: return "com.sun.rave.web.ui.ImageHyperlink";
171: }
172:
173: // align
174: private String align = null;
175:
176: /**
177: * <p>Specifies the position of the image with respect to its context.
178: * Valid values are: bottom (the default); middle; top; left; right.</p>
179: */
180: public String getAlign() {
181: if (this .align != null) {
182: return this .align;
183: }
184: ValueBinding _vb = getValueBinding("align");
185: if (_vb != null) {
186: return (String) _vb.getValue(getFacesContext());
187: }
188: return null;
189: }
190:
191: /**
192: * <p>Specifies the position of the image with respect to its context.
193: * Valid values are: bottom (the default); middle; top; left; right.</p>
194: * @see #getAlign()
195: */
196: public void setAlign(String align) {
197: this .align = align;
198: }
199:
200: // alt
201: private String alt = null;
202:
203: /**
204: * <p>Alternative text description used by screen reader tools</p>
205: */
206: public String getAlt() {
207: if (this .alt != null) {
208: return this .alt;
209: }
210: ValueBinding _vb = getValueBinding("alt");
211: if (_vb != null) {
212: return (String) _vb.getValue(getFacesContext());
213: }
214: return null;
215: }
216:
217: /**
218: * <p>Alternative text description used by screen reader tools</p>
219: * @see #getAlt()
220: */
221: public void setAlt(String alt) {
222: this .alt = alt;
223: }
224:
225: // border
226: private int border = Integer.MIN_VALUE;
227: private boolean border_set = false;
228:
229: /**
230: * <p>Specifies the width of the img border in pixels.
231: * The default value for this attribute depends on the client browser</p>
232: */
233: public int getBorder() {
234: if (this .border_set) {
235: return this .border;
236: }
237: ValueBinding _vb = getValueBinding("border");
238: if (_vb != null) {
239: Object _result = _vb.getValue(getFacesContext());
240: if (_result == null) {
241: return Integer.MIN_VALUE;
242: } else {
243: return ((Integer) _result).intValue();
244: }
245: }
246: return Integer.MIN_VALUE;
247: }
248:
249: /**
250: * <p>Specifies the width of the img border in pixels.
251: * The default value for this attribute depends on the client browser</p>
252: * @see #getBorder()
253: */
254: public void setBorder(int border) {
255: this .border = border;
256: this .border_set = true;
257: }
258:
259: // height
260: private int height = Integer.MIN_VALUE;
261: private boolean height_set = false;
262:
263: /**
264: * <p>When specified, the width and height attributes tell the client browser to override the natural image or object size in favor of these values, specified in pixels. Some browsers might not support this behavior.</p>
265: */
266: public int getHeight() {
267: if (this .height_set) {
268: return this .height;
269: }
270: ValueBinding _vb = getValueBinding("height");
271: if (_vb != null) {
272: Object _result = _vb.getValue(getFacesContext());
273: if (_result == null) {
274: return Integer.MIN_VALUE;
275: } else {
276: return ((Integer) _result).intValue();
277: }
278: }
279: return Integer.MIN_VALUE;
280: }
281:
282: /**
283: * <p>When specified, the width and height attributes tell the client browser to override the natural image or object size in favor of these values, specified in pixels. Some browsers might not support this behavior.</p>
284: * @see #getHeight()
285: */
286: public void setHeight(int height) {
287: this .height = height;
288: this .height_set = true;
289: }
290:
291: // hspace
292: private int hspace = Integer.MIN_VALUE;
293: private boolean hspace_set = false;
294:
295: /**
296: * <p>Specifies the amount of white space in pixels to be inserted to the left and
297: * right of the image. The default value is not specified but is
298: * generally a small, non-zero size.</p>
299: */
300: public int getHspace() {
301: if (this .hspace_set) {
302: return this .hspace;
303: }
304: ValueBinding _vb = getValueBinding("hspace");
305: if (_vb != null) {
306: Object _result = _vb.getValue(getFacesContext());
307: if (_result == null) {
308: return Integer.MIN_VALUE;
309: } else {
310: return ((Integer) _result).intValue();
311: }
312: }
313: return Integer.MIN_VALUE;
314: }
315:
316: /**
317: * <p>Specifies the amount of white space in pixels to be inserted to the left and
318: * right of the image. The default value is not specified but is
319: * generally a small, non-zero size.</p>
320: * @see #getHspace()
321: */
322: public void setHspace(int hspace) {
323: this .hspace = hspace;
324: this .hspace_set = true;
325: }
326:
327: // icon
328: private String icon = null;
329:
330: /**
331: * <p>The identifier of the desired theme image.</p>
332: */
333: public String getIcon() {
334: if (this .icon != null) {
335: return this .icon;
336: }
337: ValueBinding _vb = getValueBinding("icon");
338: if (_vb != null) {
339: return (String) _vb.getValue(getFacesContext());
340: }
341: return null;
342: }
343:
344: /**
345: * <p>The identifier of the desired theme image.</p>
346: * @see #getIcon()
347: */
348: public void setIcon(String icon) {
349: this .icon = icon;
350: }
351:
352: // imageURL
353: private String imageURL = null;
354:
355: /**
356: * <p>Absolute or relative URL to the image to be rendered.</p>
357: */
358: public String getImageURL() {
359: if (this .imageURL != null) {
360: return this .imageURL;
361: }
362: ValueBinding _vb = getValueBinding("imageURL");
363: if (_vb != null) {
364: return (String) _vb.getValue(getFacesContext());
365: }
366: return null;
367: }
368:
369: /**
370: * <p>Absolute or relative URL to the image to be rendered.</p>
371: * @see #getImageURL()
372: */
373: public void setImageURL(String imageURL) {
374: this .imageURL = imageURL;
375: }
376:
377: // textPosition
378: private String textPosition = null;
379:
380: /**
381: * <p>Specifies where the text will be placed relative to the image. The valid
382: * values currently are "right" or "left". There will be support in the
383: * future for "top" and "bottom".</p>
384: */
385: public String getTextPosition() {
386: if (this .textPosition != null) {
387: return this .textPosition;
388: }
389: ValueBinding _vb = getValueBinding("textPosition");
390: if (_vb != null) {
391: return (String) _vb.getValue(getFacesContext());
392: }
393: return "right";
394: }
395:
396: /**
397: * <p>Specifies where the text will be placed relative to the image. The valid
398: * values currently are "right" or "left". There will be support in the
399: * future for "top" and "bottom".</p>
400: * @see #getTextPosition()
401: */
402: public void setTextPosition(String textPosition) {
403: this .textPosition = textPosition;
404: }
405:
406: // visible
407: private boolean visible = false;
408: private boolean visible_set = false;
409:
410: /**
411: * <p>Use the visible attribute to indicate whether the component should be
412: * viewable by the user in the rendered HTML page. If set to false, the
413: * HTML code for the component is present in the page, but the component
414: * is hidden with style attributes. By default, visible is set to true, so
415: * HTML for the component HTML is included and visible to the user. If the
416: * component is not visible, it can still be processed on subsequent form
417: * submissions because the HTML is present.</p>
418: */
419: public boolean isVisible() {
420: if (this .visible_set) {
421: return this .visible;
422: }
423: ValueBinding _vb = getValueBinding("visible");
424: if (_vb != null) {
425: Object _result = _vb.getValue(getFacesContext());
426: if (_result == null) {
427: return false;
428: } else {
429: return ((Boolean) _result).booleanValue();
430: }
431: }
432: return true;
433: }
434:
435: /**
436: * <p>Use the visible attribute to indicate whether the component should be
437: * viewable by the user in the rendered HTML page. If set to false, the
438: * HTML code for the component is present in the page, but the component
439: * is hidden with style attributes. By default, visible is set to true, so
440: * HTML for the component HTML is included and visible to the user. If the
441: * component is not visible, it can still be processed on subsequent form
442: * submissions because the HTML is present.</p>
443: * @see #isVisible()
444: */
445: public void setVisible(boolean visible) {
446: this .visible = visible;
447: this .visible_set = true;
448: }
449:
450: // vspace
451: private int vspace = Integer.MIN_VALUE;
452: private boolean vspace_set = false;
453:
454: /**
455: * <p>Specifies the amount of white space in pixels to be inserted above and below the
456: * image. The default value is not specified but is generally a small,
457: * non-zero size.</p>
458: */
459: public int getVspace() {
460: if (this .vspace_set) {
461: return this .vspace;
462: }
463: ValueBinding _vb = getValueBinding("vspace");
464: if (_vb != null) {
465: Object _result = _vb.getValue(getFacesContext());
466: if (_result == null) {
467: return Integer.MIN_VALUE;
468: } else {
469: return ((Integer) _result).intValue();
470: }
471: }
472: return Integer.MIN_VALUE;
473: }
474:
475: /**
476: * <p>Specifies the amount of white space in pixels to be inserted above and below the
477: * image. The default value is not specified but is generally a small,
478: * non-zero size.</p>
479: * @see #getVspace()
480: */
481: public void setVspace(int vspace) {
482: this .vspace = vspace;
483: this .vspace_set = true;
484: }
485:
486: // width
487: private int width = Integer.MIN_VALUE;
488: private boolean width_set = false;
489:
490: /**
491: * <p>Image width override. When specified, the width and height attributes
492: * tell user agents to override the natural image or object size in favor
493: * of these values.</p>
494: */
495: public int getWidth() {
496: if (this .width_set) {
497: return this .width;
498: }
499: ValueBinding _vb = getValueBinding("width");
500: if (_vb != null) {
501: Object _result = _vb.getValue(getFacesContext());
502: if (_result == null) {
503: return Integer.MIN_VALUE;
504: } else {
505: return ((Integer) _result).intValue();
506: }
507: }
508: return Integer.MIN_VALUE;
509: }
510:
511: /**
512: * <p>Image width override. When specified, the width and height attributes
513: * tell user agents to override the natural image or object size in favor
514: * of these values.</p>
515: * @see #getWidth()
516: */
517: public void setWidth(int width) {
518: this .width = width;
519: this .width_set = true;
520: }
521:
522: /**
523: * <p>Restore the state of this component.</p>
524: */
525: public void restoreState(FacesContext _context, Object _state) {
526: Object _values[] = (Object[]) _state;
527: super .restoreState(_context, _values[0]);
528: this .align = (String) _values[1];
529: this .alt = (String) _values[2];
530: this .border = ((Integer) _values[3]).intValue();
531: this .border_set = ((Boolean) _values[4]).booleanValue();
532: this .height = ((Integer) _values[5]).intValue();
533: this .height_set = ((Boolean) _values[6]).booleanValue();
534: this .hspace = ((Integer) _values[7]).intValue();
535: this .hspace_set = ((Boolean) _values[8]).booleanValue();
536: this .icon = (String) _values[9];
537: this .imageURL = (String) _values[10];
538: this .textPosition = (String) _values[11];
539: this .visible = ((Boolean) _values[12]).booleanValue();
540: this .visible_set = ((Boolean) _values[13]).booleanValue();
541: this .vspace = ((Integer) _values[14]).intValue();
542: this .vspace_set = ((Boolean) _values[15]).booleanValue();
543: this .width = ((Integer) _values[16]).intValue();
544: this .width_set = ((Boolean) _values[17]).booleanValue();
545: }
546:
547: /**
548: * <p>Save the state of this component.</p>
549: */
550: public Object saveState(FacesContext _context) {
551: Object _values[] = new Object[18];
552: _values[0] = super .saveState(_context);
553: _values[1] = this .align;
554: _values[2] = this .alt;
555: _values[3] = new Integer(this .border);
556: _values[4] = this .border_set ? Boolean.TRUE : Boolean.FALSE;
557: _values[5] = new Integer(this .height);
558: _values[6] = this .height_set ? Boolean.TRUE : Boolean.FALSE;
559: _values[7] = new Integer(this .hspace);
560: _values[8] = this .hspace_set ? Boolean.TRUE : Boolean.FALSE;
561: _values[9] = this .icon;
562: _values[10] = this .imageURL;
563: _values[11] = this .textPosition;
564: _values[12] = this .visible ? Boolean.TRUE : Boolean.FALSE;
565: _values[13] = this .visible_set ? Boolean.TRUE : Boolean.FALSE;
566: _values[14] = new Integer(this .vspace);
567: _values[15] = this .vspace_set ? Boolean.TRUE : Boolean.FALSE;
568: _values[16] = new Integer(this .width);
569: _values[17] = this.width_set ? Boolean.TRUE : Boolean.FALSE;
570: return _values;
571: }
572:
573: }
|