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: * Use this tag to render references to theme resource files on a
051: * page where the <code>ui:head</code> component cannot be used.
052: *
053: * <h3>Configuring the <code>ui:themeLinks</code> Tag</h3>
054: *
055: * <p>If no attributes are specified, the component renders a
056: * <code>link</code> to the CSS stylesheet class(es) and a
057: * <code>script</code> element with a reference to the JavaScript
058: * functions definition file required by the Sun Java Web UI
059: * Components. </p>
060: *
061: * <p>To suppress rendering of the <code>script</code> element, set the
062: * <code>javaScript</code> attribute value to false. </p>
063: *
064: * <p>To suppress rendering of the <code>link</code> element, set the
065: * <code>styleSheet</code> attribute value to false. </p>
066: *
067: * <p>To render a style element with an inline import of the stylesheet
068: * definitions, set the
069: * <code>styleSheetInline</code> attribute value to true. </p>
070: *
071: * <h3>Example</h3>
072: *
073: * <pre>
074: * <head>
075: * <title>ThemeLinks test</title>
076: * <ui:themeLinks styleSheetInline="true"/>
077: * </head>
078: * </pre>
079: * <p>Auto-generated component class.
080: * Do <strong>NOT</strong> modify; all changes
081: * <strong>will</strong> be lost!</p>
082: */
083:
084: public abstract class ThemeLinksBase extends
085: javax.faces.component.UIComponentBase {
086:
087: /**
088: * <p>Construct a new <code>ThemeLinksBase</code>.</p>
089: */
090: public ThemeLinksBase() {
091: super ();
092: setRendererType("com.sun.rave.web.ui.ThemeLinks");
093: }
094:
095: /**
096: * <p>Return the identifier of the component family to which this
097: * component belongs. This identifier, in conjunction with the value
098: * of the <code>rendererType</code> property, may be used to select
099: * the appropriate {@link Renderer} for this component instance.</p>
100: */
101: public String getFamily() {
102: return "com.sun.rave.web.ui.ThemeLinks";
103: }
104:
105: // javaScript
106: private boolean javaScript = false;
107: private boolean javaScript_set = false;
108:
109: /**
110: * <p>If the <code>javaScript</code> attribute is true, a <code>script</code>
111: * element with a reference to the JavaScript file that defines the
112: * client side behaviour of the Sun Java Web UI Components is
113: * rendered. The default value is true. This component is primarily
114: * intended for portlet
115: * environments. In a web application, this functionality is
116: * automatically provided by the <code>ui:head</code>
117: * component.</p>
118: */
119: public boolean isJavaScript() {
120: if (this .javaScript_set) {
121: return this .javaScript;
122: }
123: ValueBinding _vb = getValueBinding("javaScript");
124: if (_vb != null) {
125: Object _result = _vb.getValue(getFacesContext());
126: if (_result == null) {
127: return false;
128: } else {
129: return ((Boolean) _result).booleanValue();
130: }
131: }
132: return true;
133: }
134:
135: /**
136: * <p>If the <code>javaScript</code> attribute is true, a <code>script</code>
137: * element with a reference to the JavaScript file that defines the
138: * client side behaviour of the Sun Java Web UI Components is
139: * rendered. The default value is true. This component is primarily
140: * intended for portlet
141: * environments. In a web application, this functionality is
142: * automatically provided by the <code>ui:head</code>
143: * component.</p>
144: * @see #isJavaScript()
145: */
146: public void setJavaScript(boolean javaScript) {
147: this .javaScript = javaScript;
148: this .javaScript_set = true;
149: }
150:
151: // styleSheet
152: private boolean styleSheet = false;
153: private boolean styleSheet_set = false;
154:
155: /**
156: * <p>If the <code>styleSheet</code> attribute is true, a <code>link</code>
157: * element with a reference to the CSS stylesheet that defines the
158: * appearance of the Sun Java Web UI Components is
159: * rendered. The default value is true.
160: * This component is primarily intended for portlet
161: * environments. In a web application, this functionality is
162: * automatically provided by the <code>ui:head</code>
163: * component.</p>
164: */
165: public boolean isStyleSheet() {
166: if (this .styleSheet_set) {
167: return this .styleSheet;
168: }
169: ValueBinding _vb = getValueBinding("styleSheet");
170: if (_vb != null) {
171: Object _result = _vb.getValue(getFacesContext());
172: if (_result == null) {
173: return false;
174: } else {
175: return ((Boolean) _result).booleanValue();
176: }
177: }
178: return true;
179: }
180:
181: /**
182: * <p>If the <code>styleSheet</code> attribute is true, a <code>link</code>
183: * element with a reference to the CSS stylesheet that defines the
184: * appearance of the Sun Java Web UI Components is
185: * rendered. The default value is true.
186: * This component is primarily intended for portlet
187: * environments. In a web application, this functionality is
188: * automatically provided by the <code>ui:head</code>
189: * component.</p>
190: * @see #isStyleSheet()
191: */
192: public void setStyleSheet(boolean styleSheet) {
193: this .styleSheet = styleSheet;
194: this .styleSheet_set = true;
195: }
196:
197: // styleSheetInline
198: private boolean styleSheetInline = false;
199: private boolean styleSheetInline_set = false;
200:
201: /**
202: * <p>If the <code>styleSheetInline</code> attribute is true, the
203: * stylesheet that defines the appearance of the Sun Java Web UI
204: * Components is rendered inline. The default value is true.
205: * This component is primarily
206: * intended for portlet environments. In a web application, this
207: * functionality is automatically provided by the
208: * <code>ui:head</code> component.</p>
209: */
210: public boolean isStyleSheetInline() {
211: if (this .styleSheetInline_set) {
212: return this .styleSheetInline;
213: }
214: ValueBinding _vb = getValueBinding("styleSheetInline");
215: if (_vb != null) {
216: Object _result = _vb.getValue(getFacesContext());
217: if (_result == null) {
218: return false;
219: } else {
220: return ((Boolean) _result).booleanValue();
221: }
222: }
223: return false;
224: }
225:
226: /**
227: * <p>If the <code>styleSheetInline</code> attribute is true, the
228: * stylesheet that defines the appearance of the Sun Java Web UI
229: * Components is rendered inline. The default value is true.
230: * This component is primarily
231: * intended for portlet environments. In a web application, this
232: * functionality is automatically provided by the
233: * <code>ui:head</code> component.</p>
234: * @see #isStyleSheetInline()
235: */
236: public void setStyleSheetInline(boolean styleSheetInline) {
237: this .styleSheetInline = styleSheetInline;
238: this .styleSheetInline_set = true;
239: }
240:
241: /**
242: * <p>Restore the state of this component.</p>
243: */
244: public void restoreState(FacesContext _context, Object _state) {
245: Object _values[] = (Object[]) _state;
246: super .restoreState(_context, _values[0]);
247: this .javaScript = ((Boolean) _values[1]).booleanValue();
248: this .javaScript_set = ((Boolean) _values[2]).booleanValue();
249: this .styleSheet = ((Boolean) _values[3]).booleanValue();
250: this .styleSheet_set = ((Boolean) _values[4]).booleanValue();
251: this .styleSheetInline = ((Boolean) _values[5]).booleanValue();
252: this .styleSheetInline_set = ((Boolean) _values[6])
253: .booleanValue();
254: }
255:
256: /**
257: * <p>Save the state of this component.</p>
258: */
259: public Object saveState(FacesContext _context) {
260: Object _values[] = new Object[7];
261: _values[0] = super .saveState(_context);
262: _values[1] = this .javaScript ? Boolean.TRUE : Boolean.FALSE;
263: _values[2] = this .javaScript_set ? Boolean.TRUE : Boolean.FALSE;
264: _values[3] = this .styleSheet ? Boolean.TRUE : Boolean.FALSE;
265: _values[4] = this .styleSheet_set ? Boolean.TRUE : Boolean.FALSE;
266: _values[5] = this .styleSheetInline ? Boolean.TRUE
267: : Boolean.FALSE;
268: _values[6] = this.styleSheetInline_set ? Boolean.TRUE
269: : Boolean.FALSE;
270: return _values;
271: }
272:
273: }
|