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: * <p> Use the <code>ui:tree</code> tag to display a tree structure in the
051: * rendered HTML page. Trees are often used for navigating in a web
052: * application.</p>
053: *
054: * <h3>HTML Elements and Layout</h3>
055: *
056: * <p> The Tree component defines and renders a tree structure. A tree
057: * structure is commonly used for navigation through data, as in file
058: * system navigators. The base, or root, of the tree is shown at the top,
059: * with the branches going downward.</p>
060: *
061: * <p> The tree is rendered with <code><div></code> XHTML elements which
062: * define rows as well as nesting within the tree.</p>
063: *
064: * <p> The <code>ui:tree</code> tag is the root of the tree, and acts as a
065: * container for the <code>ui:treeNode</code> tags. The
066: * <code>ui:treeNode</code> tags add branches, or nodes, to the tree. In
067: * the rendered web page, nodes can be expanded and collapsed when you
068: * click on small icons next to the nodes. In addition, the node is
069: * highlighted when you click on the node's hyperlink to indicate the node
070: * has focus.</p>
071: *
072: * <p> The <code>ui:tree</code> tag provides the ability to render the tree
073: * root in any of the following ways:</p>
074: *
075: * <ul><li>As a single root, with a title bar to make the root visually
076: * distinctive. You must specify attributes or facets in the
077: * <code>ui:tree</code> tag to allow the title bar to be rendered.</li>
078: * <li>As a single root, without a title bar. The root looks like any
079: * other container node in the tree. You must omit attributes and
080: * facets in the <code>ui:tree</code> tag, and specify a single
081: * <code>ui:treeNode</code> as the root node, with other
082: * <code>ui:treeNode</code> tags contained within the first
083: * <code>ui:treeNode</code>.</li>
084: * <li>As a multi-root tree, without a title bar. There is no single top
085: * node, but two or more at the same level. You must omit attributes
086: * and facets in the <code>ui:tree</code> tag and include multiple
087: * <code>ui:treeNode</code> tags.</li></ul>
088: *
089: * <h4>Defining a Title Bar for the Single Root Tree</h4>
090: *
091: * <p> The title bar consists of the following elements:</p>
092: *
093: * <ul><li>A shaded background color determined by the theme.</li>
094: * <li>An optional graphic to the left of the title bar's text.</li>
095: * <li>Text or a hyperlink for the content of the title bar.</li></ul>
096: *
097: * <p> The title bar can be defined with either <code>ui:tree</code> tag
098: * attributes or facets. The title bar is rendered if the
099: * tree component includes <code>imageURL</code> property for the graphic,
100: * the <code>text</code> property for the title text, the
101: * <code>content</code> facet, or the <code>image</code> facet.</p>
102: *
103: * <p> The graphic and title text areas can be overridden with the following
104: * facets:</p>
105: *
106: * <ul><li style="clear: both">
107: * <div style="float:left; width: 100px; font-weight: bold;">
108: * <code>content</code></div>
109: * <div style="float:left; width: 30px;"><code>--</code></div>
110: * <div style="float:right; width: 75%;">
111: * Specifies the text or hyperlink for the title bar. When the
112: * <code>content</code> facet is used, the text and hyperlink
113: * properties have no effect.</div></li>
114: * <li style="clear: both">
115: * <div style="float:left; width: 100px; font-weight: bold;">
116: * <code>image</code></div>
117: * <div style="float:left; width: 30px;"><code>--</code></div>
118: * <div style="float:right; width: 75%;">
119: * Specifies the image area. When the <code>image</code> facet is
120: * used, image properties have no effect.</div></li></ul>
121: * <br style="clear: both" />
122: *
123: * <h4>Defining a Tree with Multiple Roots</h4>
124: *
125: * <p> To define a tree that has multiple roots rather than a single top root,
126: * you must use the <code>ui:tree</code> tag only as a container. You
127: * should not specify attributes for the graphic or title text, or use
128: * facets in the <code>ui:tree</code> tag.</p>
129: *
130: * <p> You can use <code>ui:treeNode</code> tags as containers for other
131: * <code>ui:treeNode</code> tags, but should not use one to contain all
132: * the others to avoid the appearance of a single root.</p>
133: *
134: * <!--
135: * <h3>Theme Identifiers</h3>
136: *
137: * <p> The following identifiers are written as class values in the html.
138: * The locations are described below.</p>
139: *
140: * <ul><li><code>Tree</code> for the outer <code><div></code> around the
141: * tree component.</li>
142: * <li><code>TreeContent</code> for the <code><div></code> around the
143: * content area of the tree (or tree node) component. This is the same
144: * area that may be replaced by the <code>content</code> facet.</li>
145: * -- <li><code>TreeParentLink</code> </li> --
146: * -- <li><code>TreeLink</code> </li> --
147: * -- <li><code>TreeLinkSpace</code> </li> --
148: * -- <li><code>TreeImg</code> </li> --
149: * <li><code>TreeImgHeight</code> ensures each tree row is the correct
150: * height.</li>
151: * <li><code>TreeRootRow</code> for the <code><div></code> around
152: * the title bar.</li>
153: * <li><code>TreeRootRowHeader</code> for the <code><div></code>
154: * above the title bar. This may be used to make the title bar
155: * taller.</li>
156: * <li><code>TreeRow</code> for the <code><div></code> around each
157: * tree node component. This includes the tree node and all its child
158: * tree nodes.</li>
159: * -- <li><code>TreeSelLink</code> </li> --
160: * -- <li><code>TreeSelRow</code> </li> --
161: * -- <li><code>TreeSelText</code> </li> --
162: * </ul>
163: * -->
164: *
165: *
166: * <h3>Client Side Javascript Functions</h3>
167: *
168: * <p> The JavaScript functions listed in the following table are defined in a
169: * file that is referenced automatically by the Tree component. The
170: * functions are called automatically in the rendered HTML. You can also
171: * call these functions independently; you may choose to do this to select
172: * or expand/collapse a TreeNode on the client.</p>
173: *
174: * <ul><li style="clear: both">
175: * <div style="float:left; width: 275px; font-weight: bold;">
176: * <code>clearHightlight(treeNode)</code></div>
177: * <div style="float:left; width: 30px;"><code>--</code></div>
178: * <div style="float:right; width: 65%;">
179: * This function clears the highlighting for a particular
180: * TreeNode. The <code>treeNode</code> passed in should be the
181: * <div> around the html for the <code>TreeNode</code>. This
182: * may be obtained by calling
183: * <code>getElementById("<TreeNode.getClidentId()>")</code>.
184: * </div></li>
185: * <li style="clear: both">
186: * <div style="float:left; width: 275px; font-weight: bold;">
187: * <code>expandCollapse(treeNode, event)</code></div>
188: * <div style="float:left; width: 30px;"><code>--</code></div>
189: * <div style="float:right; width: 65%;">
190: * This function expands or collapses the given tree node. It
191: * expects the source of the given event object (if supplied) to
192: * be a tree handle image. It will change this image to point in
193: * the correct direction (right or down). This implementation
194: * depends on the tree handle image names including
195: * "tree_handleright" and "tree_handledown" in them. Swapping
196: * "right" and "down" in these names must change the handle
197: * direction to right and down respectively.</div></li>
198: * <li style="clear: both">
199: * <div style="float:left; width: 275px; font-weight: bold;">
200: * <code>getParentTreeNode(treeId)</code></div>
201: * <div style="float:left; width: 30px;"><code>--</code></div>
202: * <div style="float:right; width: 65%;">
203: * This function returns the parent TreeNode of the given
204: * TreeNode.</div></li>
205: * <li style="clear: both">
206: * <div style="float:left; width: 275px; font-weight: bold;">
207: * <code>getSelectedTreeNode(treeId)</code></div>
208: * <div style="float:left; width: 30px;"><code>--</code></div>
209: * <div style="float:right; width: 65%;">
210: * This function returns the selected TreeNode given the treeId of
211: * the Tree.</div></li>
212: * <li style="clear: both">
213: * <div style="float:left; width: 275px; font-weight: bold;">
214: * <code>getTree(treeNode)</code></div>
215: * <div style="float:left; width: 30px;"><code>--</code></div>
216: * <div style="float:right; width: 65%;">
217: * This function provides access to the Tree object containing the
218: * given TreeNode.</div></li>
219: * <li style="clear: both">
220: * <div style="float:left; width: 275px; font-weight: bold;">
221: * <code>highlight(treeNode)</code></div>
222: * <div style="float:left; width: 30px;"><code>--</code></div>
223: * <div style="float:right; width: 65%;">
224: * This function highlights the given TreeNode. The
225: * <code>treeNode</code> passed in is the <div> around
226: * the html for the TreeNode and may be obtained by calling
227: * <code>getElementById("<TreeNode.getClidentId()>")</code>.
228: * </div></li>
229: * <li style="clear: both">
230: * <div style="float:left; width: 275px; font-weight: bold;">
231: * <code>highlightParent(treeNode)</code></div>
232: * <div style="float:left; width: 30px;"><code>--</code></div>
233: * <div style="float:right; width: 65%;">
234: * This function highlights the parent TreeNode of the given
235: * TreeNode. It only does so if the given TreeNode is <b>not</b>
236: * visible. The parent is considered the first visible parent of
237: * this TreeNode. The <code>treeNode</code> passed in is the
238: * <div> around the html for the child <code>TreeNode</code>
239: * and may be obtained by calling
240: * <code>getElementById("<TreeNode.getClidentId()>")</code>.
241: * </div></li>
242: * <li style="clear: both">
243: * <div style="float:left; width: 275px; font-weight: bold;">
244: * <code>isAnHref(event)</code></div>
245: * <div style="float:left; width: 30px;"><code>--</code></div>
246: * <div style="float:right; width: 65%;">
247: * This method checks to see if the event.target is an href, or if
248: * any of the parent nodes which contain it is an href. To
249: * considered an href, it must be an "A" tag with an "href"
250: * attribute containing atleast 4 characters. (Note: Browsers will
251: * add on the protocol if you supply a relative URL such as one
252: * starting with a '#', '/', or filename).</div></li>
253: * <li style="clear: both">
254: * <div style="float:left; width: 275px; font-weight: bold;">
255: * <code>isTreeHandle(event)</code></div>
256: * <div style="float:left; width: 30px;"><code>--</code></div>
257: * <div style="float:right; width: 65%;">
258: * This function determines if the event source was a tree handle
259: * image. This implementation depends on the tree handle image
260: * file name containing "tree_handle" and no other images
261: * containing this string.</div></li>
262: * <li style="clear: both">
263: * <div style="float:left; width: 275px; font-weight: bold;">
264: * <code>onTreeNodeClick(treeNode)</code></div>
265: * <div style="float:left; width: 30px;"><code>--</code></div>
266: * <div style="float:right; width: 65%;">
267: * This function Takes in the TreeNode <div> object that was
268: * clicked in order to process the highlighting changes that are
269: * necessary. This object may be obtained by calling
270: * <code>getElementById("<TreeNode.getClidentId()>")</code>.
271: * If this function is invoked from the TreeNode <div> object
272: * itself (as is the case when this method is implicitly called),
273: * the TreeNode object is simply the <code>this</code> variable.
274: * </div></li>
275: * <li style="clear: both">
276: * <div style="float:left; width: 275px; font-weight: bold;">
277: * <code>selectTreeNode(treeNode)</code></div>
278: * <div style="float:left; width: 30px;"><code>--</code></div>
279: * <div style="float:right; width: 65%;">
280: * This function may be used to select the given TreeNode. It will
281: * clear the previous TreeNode and select the given one.</div></li>
282: * <li style="clear: both">
283: * <div style="float:left; width: 275px; font-weight: bold;">
284: * <code>treeNodeIsExpanded(treeNode)</code></div>
285: * <div style="float:left; width: 30px;"><code>--</code></div>
286: * <div style="float:right; width: 65%;">
287: * This function determines if the given TreeNode is expanded. It
288: * returns <code>true</code> if it is, <code>false</code>
289: * otherwise.</div></li>
290: * <li style="clear: both">
291: * <div style="float:left; width: 275px; font-weight: bold;">
292: * <code>unhighlightParent(treeNode)</code></div>
293: * <div style="float:left; width: 30px;"><code>--</code></div>
294: * <div style="float:right; width: 65%;">
295: * This function un-applies parent highlighting to the parent
296: * TreeNode of the given TreeNode. It only does so if the given
297: * TreeNode is <b>not</b> visible. The parent is considered the
298: * first visible parent of this TreeNode. The
299: * <code>treeNode</code> passed in is the <div> element
300: * around the html for the TreeNode and may be obtained by calling
301: * <code>getElementById("<TreeNode.getClidentId()>")</code>.
302: * </div></li>
303: * <li style="clear: both">
304: * <div style="float:left; width: 275px; font-weight: bold;">
305: * <code>updateHightlight(id)</code></div>
306: * <div style="float:left; width: 30px;"><code>--</code></div>
307: * <div style="float:right; width: 65%;">
308: * This function updates the highlighting for the given Tree client
309: * id. This function provides a way to restore the highlighting
310: * when a Tree is reloaded in a window (necessary each page load).
311: * </div></li></ul>
312: * <br style="clear: both" />
313: *
314: * <h3>Example:</h3>
315: *
316: * <p> Below is an example showing how a tree may be defined in a JSP
317: * page:</p>
318: *
319: * <p>
320: * <code>
321: * <pre>
322: * <ui:tree id="MyTree" text="hi">
323: * <f:facet name="image">
324: * <ui:image id="image" icon="TREE_SERVER" />
325: * </f:facet>
326: * <ui:treeNode id="Node0" text="About..." />
327: * <ui:treeNode id="Node1" expanded="true" text="External URLs">
328: * <f:facet name="image">
329: * <ui:image id="image" icon="TREE_SERVER" />
330: * </f:facet>
331: * <ui:treeNode id="Node1_1" text="Sun Microsystems, Inc." url="http://www.sun.com" target="external">
332: * <f:facet name="image">
333: * <ui:image id="image" icon="TREE_STORAGE_MAJOR" />
334: * </f:facet>
335: * </ui:treeNode>
336: * <ui:treeNode id="Node1_2" text="Search Engines">
337: * <ui:treeNode id="Node1_2_1" text="Google" url="http://www.google.com" imageURL="../images/google.jpg" target="external" />
338: * <ui:treeNode id="Node1_2_2" text="Yahoo!" url="http://www.yahoo.com" imageURL="../images/yahoo.jpg" target="external" />
339: * <ui:treeNode id="Node1_2_3" text="Lycos" url="http://www.lycos.com" target="external">
340: * <f:facet name="image">
341: * <ui:image id="image" url="http://ly.lygo.com/ly/srch/hp/dog_web_34x35.gif" height="16" width="16" />
342: * </f:facet>
343: * </ui:treeNode>
344: * </ui:treeNode>
345: * </ui:treeNode>
346: * </ui:tree>
347: * </pre>
348: * </code>
349: * </p>
350: * <p>Auto-generated component class.
351: * Do <strong>NOT</strong> modify; all changes
352: * <strong>will</strong> be lost!</p>
353: */
354:
355: public abstract class TreeBase extends
356: com.sun.rave.web.ui.component.TreeNode {
357:
358: /**
359: * <p>Construct a new <code>TreeBase</code>.</p>
360: */
361: public TreeBase() {
362: super ();
363: setRendererType("com.sun.rave.web.ui.Tree");
364: }
365:
366: /**
367: * <p>Return the identifier of the component family to which this
368: * component belongs. This identifier, in conjunction with the value
369: * of the <code>rendererType</code> property, may be used to select
370: * the appropriate {@link Renderer} for this component instance.</p>
371: */
372: public String getFamily() {
373: return "com.sun.rave.web.ui.Tree";
374: }
375:
376: // clientSide
377: private boolean clientSide = false;
378: private boolean clientSide_set = false;
379:
380: /**
381: * <p>Specifies if this <code>Tree</code> should run on the client, or if it
382: * should interact with the server. If it runs on the client, then
383: * clicking on the tree icon to expand or collapse portions of the tree
384: * will happen only on the client (browser). Otherwise, it will make a
385: * request to the server each time the tree is expanded or collapsed.</p>
386: */
387: public boolean isClientSide() {
388: if (this .clientSide_set) {
389: return this .clientSide;
390: }
391: ValueBinding _vb = getValueBinding("clientSide");
392: if (_vb != null) {
393: Object _result = _vb.getValue(getFacesContext());
394: if (_result == null) {
395: return false;
396: } else {
397: return ((Boolean) _result).booleanValue();
398: }
399: }
400: return false;
401: }
402:
403: /**
404: * <p>Specifies if this <code>Tree</code> should run on the client, or if it
405: * should interact with the server. If it runs on the client, then
406: * clicking on the tree icon to expand or collapse portions of the tree
407: * will happen only on the client (browser). Otherwise, it will make a
408: * request to the server each time the tree is expanded or collapsed.</p>
409: * @see #isClientSide()
410: */
411: public void setClientSide(boolean clientSide) {
412: this .clientSide = clientSide;
413: this .clientSide_set = true;
414: }
415:
416: // expandOnSelect
417: private boolean expandOnSelect = false;
418: private boolean expandOnSelect_set = false;
419:
420: /**
421: * <p>Flag indicating that folder / container nodes will automatically expand
422: * when they are selected. This attribute is true by default. If you want a tree's container
423: * nodes to expand only when the handle icons are clicked, set expandOnSelect to false.</p>
424: */
425: public boolean isExpandOnSelect() {
426: if (this .expandOnSelect_set) {
427: return this .expandOnSelect;
428: }
429: ValueBinding _vb = getValueBinding("expandOnSelect");
430: if (_vb != null) {
431: Object _result = _vb.getValue(getFacesContext());
432: if (_result == null) {
433: return false;
434: } else {
435: return ((Boolean) _result).booleanValue();
436: }
437: }
438: return true;
439: }
440:
441: /**
442: * <p>Flag indicating that folder / container nodes will automatically expand
443: * when they are selected. This attribute is true by default. If you want a tree's container
444: * nodes to expand only when the handle icons are clicked, set expandOnSelect to false.</p>
445: * @see #isExpandOnSelect()
446: */
447: public void setExpandOnSelect(boolean expandOnSelect) {
448: this .expandOnSelect = expandOnSelect;
449: this .expandOnSelect_set = true;
450: }
451:
452: // immediate
453: private boolean immediate = false;
454: private boolean immediate_set = false;
455:
456: /**
457: * <p>Indicate that event handling for this component should be
458: * handled immediately (in Apply Request Values phase) rather than
459: * waiting until Invoke Application phase.</p>
460: */
461: public boolean isImmediate() {
462: if (this .immediate_set) {
463: return this .immediate;
464: }
465: ValueBinding _vb = getValueBinding("immediate");
466: if (_vb != null) {
467: Object _result = _vb.getValue(getFacesContext());
468: if (_result == null) {
469: return false;
470: } else {
471: return ((Boolean) _result).booleanValue();
472: }
473: }
474: return false;
475: }
476:
477: /**
478: * <p>Indicate that event handling for this component should be
479: * handled immediately (in Apply Request Values phase) rather than
480: * waiting until Invoke Application phase.</p>
481: * @see #isImmediate()
482: */
483: public void setImmediate(boolean immediate) {
484: this .immediate = immediate;
485: this .immediate_set = true;
486: }
487:
488: // required
489: private boolean required = false;
490: private boolean required_set = false;
491:
492: /**
493: * <p>Indicates that the user must select a value for this tree.</p>
494: */
495: public boolean isRequired() {
496: if (this .required_set) {
497: return this .required;
498: }
499: ValueBinding _vb = getValueBinding("required");
500: if (_vb != null) {
501: Object _result = _vb.getValue(getFacesContext());
502: if (_result == null) {
503: return false;
504: } else {
505: return ((Boolean) _result).booleanValue();
506: }
507: }
508: return false;
509: }
510:
511: /**
512: * <p>Indicates that the user must select a value for this tree.</p>
513: * @see #isRequired()
514: */
515: public void setRequired(boolean required) {
516: this .required = required;
517: this .required_set = true;
518: }
519:
520: // selected
521: private String selected = null;
522:
523: /**
524: * <p>Specifies the client id of the selected tree node.</p>
525: */
526: public String getSelected() {
527: if (this .selected != null) {
528: return this .selected;
529: }
530: ValueBinding _vb = getValueBinding("selected");
531: if (_vb != null) {
532: return (String) _vb.getValue(getFacesContext());
533: }
534: return null;
535: }
536:
537: /**
538: * <p>Specifies the client id of the selected tree node.</p>
539: * @see #getSelected()
540: */
541: public void setSelected(String selected) {
542: this .selected = selected;
543: }
544:
545: // style
546: private String style = null;
547:
548: /**
549: * <p>CSS style(s) to be applied when this component is rendered.</p>
550: */
551: public String getStyle() {
552: if (this .style != null) {
553: return this .style;
554: }
555: ValueBinding _vb = getValueBinding("style");
556: if (_vb != null) {
557: return (String) _vb.getValue(getFacesContext());
558: }
559: return null;
560: }
561:
562: /**
563: * <p>CSS style(s) to be applied when this component is rendered.</p>
564: * @see #getStyle()
565: */
566: public void setStyle(String style) {
567: this .style = style;
568: }
569:
570: // styleClass
571: private String styleClass = null;
572:
573: /**
574: * <p>CSS style class(es) to be applied when this component is rendered.</p>
575: */
576: public String getStyleClass() {
577: if (this .styleClass != null) {
578: return this .styleClass;
579: }
580: ValueBinding _vb = getValueBinding("styleClass");
581: if (_vb != null) {
582: return (String) _vb.getValue(getFacesContext());
583: }
584: return null;
585: }
586:
587: /**
588: * <p>CSS style class(es) to be applied when this component is rendered.</p>
589: * @see #getStyleClass()
590: */
591: public void setStyleClass(String styleClass) {
592: this .styleClass = styleClass;
593: }
594:
595: // text
596: private String text = null;
597:
598: /**
599: * <p>The text displayed at root of the tree</p>
600: */
601: public String getText() {
602: if (this .text != null) {
603: return this .text;
604: }
605: ValueBinding _vb = getValueBinding("text");
606: if (_vb != null) {
607: return (String) _vb.getValue(getFacesContext());
608: }
609: return null;
610: }
611:
612: /**
613: * <p>The text displayed at root of the tree</p>
614: * @see #getText()
615: */
616: public void setText(String text) {
617: this .text = text;
618: }
619:
620: // visible
621: private boolean visible = false;
622: private boolean visible_set = false;
623:
624: /**
625: * <p>Use the visible attribute to indicate whether the component should be
626: * viewable by the user in the rendered HTML page. If set to false, the
627: * HTML code for the component is present in the page, but the component
628: * is hidden with style attributes. By default, visible is set to true, so
629: * HTML for the component HTML is included and visible to the user. If the
630: * component is not visible, it can still be processed on subsequent form
631: * submissions because the HTML is present.</p>
632: */
633: public boolean isVisible() {
634: if (this .visible_set) {
635: return this .visible;
636: }
637: ValueBinding _vb = getValueBinding("visible");
638: if (_vb != null) {
639: Object _result = _vb.getValue(getFacesContext());
640: if (_result == null) {
641: return false;
642: } else {
643: return ((Boolean) _result).booleanValue();
644: }
645: }
646: return true;
647: }
648:
649: /**
650: * <p>Use the visible attribute to indicate whether the component should be
651: * viewable by the user in the rendered HTML page. If set to false, the
652: * HTML code for the component is present in the page, but the component
653: * is hidden with style attributes. By default, visible is set to true, so
654: * HTML for the component HTML is included and visible to the user. If the
655: * component is not visible, it can still be processed on subsequent form
656: * submissions because the HTML is present.</p>
657: * @see #isVisible()
658: */
659: public void setVisible(boolean visible) {
660: this .visible = visible;
661: this .visible_set = true;
662: }
663:
664: /**
665: * <p>Restore the state of this component.</p>
666: */
667: public void restoreState(FacesContext _context, Object _state) {
668: Object _values[] = (Object[]) _state;
669: super .restoreState(_context, _values[0]);
670: this .clientSide = ((Boolean) _values[1]).booleanValue();
671: this .clientSide_set = ((Boolean) _values[2]).booleanValue();
672: this .expandOnSelect = ((Boolean) _values[3]).booleanValue();
673: this .expandOnSelect_set = ((Boolean) _values[4]).booleanValue();
674: this .immediate = ((Boolean) _values[5]).booleanValue();
675: this .immediate_set = ((Boolean) _values[6]).booleanValue();
676: this .required = ((Boolean) _values[7]).booleanValue();
677: this .required_set = ((Boolean) _values[8]).booleanValue();
678: this .selected = (String) _values[9];
679: this .style = (String) _values[10];
680: this .styleClass = (String) _values[11];
681: this .text = (String) _values[12];
682: this .visible = ((Boolean) _values[13]).booleanValue();
683: this .visible_set = ((Boolean) _values[14]).booleanValue();
684: }
685:
686: /**
687: * <p>Save the state of this component.</p>
688: */
689: public Object saveState(FacesContext _context) {
690: Object _values[] = new Object[15];
691: _values[0] = super .saveState(_context);
692: _values[1] = this .clientSide ? Boolean.TRUE : Boolean.FALSE;
693: _values[2] = this .clientSide_set ? Boolean.TRUE : Boolean.FALSE;
694: _values[3] = this .expandOnSelect ? Boolean.TRUE : Boolean.FALSE;
695: _values[4] = this .expandOnSelect_set ? Boolean.TRUE
696: : Boolean.FALSE;
697: _values[5] = this .immediate ? Boolean.TRUE : Boolean.FALSE;
698: _values[6] = this .immediate_set ? Boolean.TRUE : Boolean.FALSE;
699: _values[7] = this .required ? Boolean.TRUE : Boolean.FALSE;
700: _values[8] = this .required_set ? Boolean.TRUE : Boolean.FALSE;
701: _values[9] = this .selected;
702: _values[10] = this .style;
703: _values[11] = this .styleClass;
704: _values[12] = this .text;
705: _values[13] = this .visible ? Boolean.TRUE : Boolean.FALSE;
706: _values[14] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
707: return _values;
708: }
709:
710: }
|