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: * Render a breadcrumb or parentage path. <br>
051: * <h3>HTML Elements and Layout</h3>
052: * This tag will render a breadcrumb (or parentage path) on a page. A breadcrumb or parentage path is a set of hyperlinks, displayed on a page to show the user's location within an application, and the physical or logical path to a page. The breadcrumbs can be used to navigate to other locations within the application.
053: * <h3>Client Side Javascript Functions</h3>
054: * none.
055: * <h3>Examples</h3>
056: * The pages which comprise breadcrumbs can be specified as child components of the breadcrumbs or by using the <code>pages</code> attribute. If the <code>pages</code> attribute is used, the value must an EL expression that identifies an array of <code>com.sun.rave.web.ui.Hyperlink</code>.<br>
057: * Breadcrumbs must be used within a <code><ui:form></code> tag.
058: * <h4>Example 1:</h4>
059: * Using child components:<br>
060: * <code>
061: * <pre>
062: * <ui:breadcrumbs id="breadcrumbs1">
063: * <ui:hyperlink url="http://google.com" label="Google"/>
064: * <ui:hyperlink url="http://yahoo.com" label="Yahoo"/>
065: * <ui:hyperlink url="http://sun.com" label="Sun"/>
066: * </ui:breadcrumbs>
067: * </pre>
068: * </code>
069: * <h4>Example 2:</h4>
070: * Using a value binding:<br>
071: * <code>
072: * <pre>
073: * <ui:breadcrumbs id="breadcrumbs2" pages="#{FieldBean.pagelist}" />
074: * </pre>
075: * </code>
076: * <br>
077: * <p>Auto-generated component class.
078: * Do <strong>NOT</strong> modify; all changes
079: * <strong>will</strong> be lost!</p>
080: */
081:
082: public abstract class BreadcrumbsBase extends
083: javax.faces.component.UICommand {
084:
085: /**
086: * <p>Construct a new <code>BreadcrumbsBase</code>.</p>
087: */
088: public BreadcrumbsBase() {
089: super ();
090: setRendererType("com.sun.rave.web.ui.Breadcrumbs");
091: }
092:
093: /**
094: * <p>Return the identifier of the component family to which this
095: * component belongs. This identifier, in conjunction with the value
096: * of the <code>rendererType</code> property, may be used to select
097: * the appropriate {@link Renderer} for this component instance.</p>
098: */
099: public String getFamily() {
100: return "com.sun.rave.web.ui.Breadcrumbs";
101: }
102:
103: // pages
104: private com.sun.rave.web.ui.component.Hyperlink[] pages = null;
105:
106: /**
107: * <p>Value binding expression that points to an array of UIComponents containing
108: * the information for the pages in the breadcrumbs.</p>
109: */
110: public com.sun.rave.web.ui.component.Hyperlink[] getPages() {
111: if (this .pages != null) {
112: return this .pages;
113: }
114: ValueBinding _vb = getValueBinding("pages");
115: if (_vb != null) {
116: return (com.sun.rave.web.ui.component.Hyperlink[]) _vb
117: .getValue(getFacesContext());
118: }
119: return null;
120: }
121:
122: /**
123: * <p>Value binding expression that points to an array of UIComponents containing
124: * the information for the pages in the breadcrumbs.</p>
125: * @see #getPages()
126: */
127: public void setPages(com.sun.rave.web.ui.component.Hyperlink[] pages) {
128: this .pages = pages;
129: }
130:
131: // style
132: private String style = null;
133:
134: /**
135: * <p>CSS style(s) to be applied when this component is rendered.</p>
136: */
137: public String getStyle() {
138: if (this .style != null) {
139: return this .style;
140: }
141: ValueBinding _vb = getValueBinding("style");
142: if (_vb != null) {
143: return (String) _vb.getValue(getFacesContext());
144: }
145: return null;
146: }
147:
148: /**
149: * <p>CSS style(s) to be applied when this component is rendered.</p>
150: * @see #getStyle()
151: */
152: public void setStyle(String style) {
153: this .style = style;
154: }
155:
156: // styleClass
157: private String styleClass = null;
158:
159: /**
160: * <p>CSS style class(es) to be applied when this component is rendered.</p>
161: */
162: public String getStyleClass() {
163: if (this .styleClass != null) {
164: return this .styleClass;
165: }
166: ValueBinding _vb = getValueBinding("styleClass");
167: if (_vb != null) {
168: return (String) _vb.getValue(getFacesContext());
169: }
170: return null;
171: }
172:
173: /**
174: * <p>CSS style class(es) to be applied when this component is rendered.</p>
175: * @see #getStyleClass()
176: */
177: public void setStyleClass(String styleClass) {
178: this .styleClass = styleClass;
179: }
180:
181: // tabIndex
182: private int tabIndex = Integer.MIN_VALUE;
183: private boolean tabIndex_set = false;
184:
185: /**
186: * <p>The position of this component in the tabbing order sequence</p>
187: */
188: public int getTabIndex() {
189: if (this .tabIndex_set) {
190: return this .tabIndex;
191: }
192: ValueBinding _vb = getValueBinding("tabIndex");
193: if (_vb != null) {
194: Object _result = _vb.getValue(getFacesContext());
195: if (_result == null) {
196: return Integer.MIN_VALUE;
197: } else {
198: return ((Integer) _result).intValue();
199: }
200: }
201: return Integer.MIN_VALUE;
202: }
203:
204: /**
205: * <p>The position of this component in the tabbing order sequence</p>
206: * @see #getTabIndex()
207: */
208: public void setTabIndex(int tabIndex) {
209: this .tabIndex = tabIndex;
210: this .tabIndex_set = true;
211: }
212:
213: // visible
214: private boolean visible = false;
215: private boolean visible_set = false;
216:
217: /**
218: * <p>Use the visible attribute to indicate whether the component should be
219: * viewable by the user in the rendered HTML page. If set to false, the
220: * HTML code for the component is present in the page, but the component
221: * is hidden with style attributes. By default, visible is set to true, so
222: * HTML for the component HTML is included and visible to the user. If the
223: * component is not visible, it can still be processed on subsequent form
224: * submissions because the HTML is present.</p>
225: */
226: public boolean isVisible() {
227: if (this .visible_set) {
228: return this .visible;
229: }
230: ValueBinding _vb = getValueBinding("visible");
231: if (_vb != null) {
232: Object _result = _vb.getValue(getFacesContext());
233: if (_result == null) {
234: return false;
235: } else {
236: return ((Boolean) _result).booleanValue();
237: }
238: }
239: return true;
240: }
241:
242: /**
243: * <p>Use the visible attribute to indicate whether the component should be
244: * viewable by the user in the rendered HTML page. If set to false, the
245: * HTML code for the component is present in the page, but the component
246: * is hidden with style attributes. By default, visible is set to true, so
247: * HTML for the component HTML is included and visible to the user. If the
248: * component is not visible, it can still be processed on subsequent form
249: * submissions because the HTML is present.</p>
250: * @see #isVisible()
251: */
252: public void setVisible(boolean visible) {
253: this .visible = visible;
254: this .visible_set = true;
255: }
256:
257: /**
258: * <p>Restore the state of this component.</p>
259: */
260: public void restoreState(FacesContext _context, Object _state) {
261: Object _values[] = (Object[]) _state;
262: super .restoreState(_context, _values[0]);
263: this .pages = (com.sun.rave.web.ui.component.Hyperlink[]) _values[1];
264: this .style = (String) _values[2];
265: this .styleClass = (String) _values[3];
266: this .tabIndex = ((Integer) _values[4]).intValue();
267: this .tabIndex_set = ((Boolean) _values[5]).booleanValue();
268: this .visible = ((Boolean) _values[6]).booleanValue();
269: this .visible_set = ((Boolean) _values[7]).booleanValue();
270: }
271:
272: /**
273: * <p>Save the state of this component.</p>
274: */
275: public Object saveState(FacesContext _context) {
276: Object _values[] = new Object[8];
277: _values[0] = super .saveState(_context);
278: _values[1] = this .pages;
279: _values[2] = this .style;
280: _values[3] = this .styleClass;
281: _values[4] = new Integer(this .tabIndex);
282: _values[5] = this .tabIndex_set ? Boolean.TRUE : Boolean.FALSE;
283: _values[6] = this .visible ? Boolean.TRUE : Boolean.FALSE;
284: _values[7] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
285: return _values;
286: }
287:
288: }
|