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: * The tab tag is used for inserting a Tab component into a TabSet.
051: * The tab tag simply extends <a href="hyperlink.html">ui:hyperlink</a> differing
052: * only in the value rendered by default for the class attriubte<br>
053: * <h3>HTML Elements and Layout</h3>
054: * The tab tag will render an XHTML anchor tag. Its output is identical to that of
055: * <a href="hyperlink.html">ui:hyperlink</a> except for the value of the class
056: * attribute
057: * <br>
058: * <h3>Client Side Javascript Functions</h3>
059: * none.
060: * <br>
061: * <h3>Examples</h3>
062: * <p><em>Please see <a href="tabSet.html">the tabSet tlddoc</a> for an example of
063: * defining tabs via a TabSet component binding</em></p>
064: * <p><strong>Define three tabs as part of a TabSet</strong></p>
065: * <p><code><ui:tabSet id="MyTabs" selected="tab1" ><br>
066: * <ui:tab id="tab1"
067: * text="Tab 1" action="#{TabSetBean.tab1Clicked}" /><br>
068: * <ui:tab id="tab2"
069: * text="Tab 2" action="#{TabSetBean.tab2Clicked}" /><br>
070: * <ui:tab id="tab3"
071: * text="Tab 3" action="#{TabSetBean.tab3Clicked}" /><br>
072: * </ui:tabSet ><br>
073: * </code></p>
074: * <p>Auto-generated component class.
075: * Do <strong>NOT</strong> modify; all changes
076: * <strong>will</strong> be lost!</p>
077: */
078:
079: public abstract class TabBase extends
080: com.sun.rave.web.ui.component.Hyperlink {
081:
082: /**
083: * <p>Construct a new <code>TabBase</code>.</p>
084: */
085: public TabBase() {
086: super ();
087: setRendererType("com.sun.rave.web.ui.Tab");
088: }
089:
090: /**
091: * <p>Return the identifier of the component family to which this
092: * component belongs. This identifier, in conjunction with the value
093: * of the <code>rendererType</code> property, may be used to select
094: * the appropriate {@link Renderer} for this component instance.</p>
095: */
096: public String getFamily() {
097: return "com.sun.rave.web.ui.Tab";
098: }
099:
100: // selectedChildId
101: private String selectedChildId = null;
102:
103: /**
104: * <p>The id of this tab's currently selected Tab child or null if one is not selected.</p>
105: */
106: public String getSelectedChildId() {
107: if (this .selectedChildId != null) {
108: return this .selectedChildId;
109: }
110: ValueBinding _vb = getValueBinding("selectedChildId");
111: if (_vb != null) {
112: return (String) _vb.getValue(getFacesContext());
113: }
114: return null;
115: }
116:
117: /**
118: * <p>The id of this tab's currently selected Tab child or null if one is not selected.</p>
119: * @see #getSelectedChildId()
120: */
121: public void setSelectedChildId(String selectedChildId) {
122: this .selectedChildId = selectedChildId;
123: }
124:
125: /**
126: * <p>Restore the state of this component.</p>
127: */
128: public void restoreState(FacesContext _context, Object _state) {
129: Object _values[] = (Object[]) _state;
130: super .restoreState(_context, _values[0]);
131: this .selectedChildId = (String) _values[1];
132: }
133:
134: /**
135: * <p>Save the state of this component.</p>
136: */
137: public Object saveState(FacesContext _context) {
138: Object _values[] = new Object[2];
139: _values[0] = super .saveState(_context);
140: _values[1] = this.selectedChildId;
141: return _values;
142: }
143:
144: }
|