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(0, 0, 0);">Use the ui:page tag to indicate the
051: * beginning of the part of the JSP page that is used by the Sun Java Web
052: * UI Components. All the JSF components used in the page must be nested
053: * within the ui:page tag. You must use the ui:html and ui:head tags
054: * first, after the opening of the ui:page tag. Then you must use either
055: * the ui:body tag or the ui:frameset tag. The ui:page tag takes care of
056: * generating the preamble for the HTML page.</span><br>
057: * <h3 style="color: rgb(0, 0, 0);">HTML Elements and Layout</h3>
058: *
059: * <p style="color: rgb(0, 0, 0);">If the application is used in
060: * a servlet environment, the rendered HTML will include <code><?xml></code>
061: * and <code><!DOCTYPE></code> headers. The content of the headers
062: * is determined by the <code>ui:page</code>
063: * attributes that you
064: * specify. Use the frameset and xhtml attributes to create the <code><!DOCTYPE></code>
065: * header that you want. For example, if you set frameset and xhtml
066: * attributes to true, the rendered <code><!DOCTYPE></code> header
067: * will indicate XHTML Frameset, as in the following example:<br>
068: * </p>
069: * <pre style="color: rgb(0, 0, 0);"><!DOCTYPE HTML <br> PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"><br><br></pre>
070: * <span style="color: rgb(0, 0, 0);">If you set both attributes to
071: * false, the rendered <code><!DOCTYPE></code>
072: * header will indicate HTML Transitional, as in the following
073: * example:<br>
074: * </span>
075: * <pre style="color: rgb(0, 0, 0);" wrap=""><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"></pre>
076: * <p style="color: rgb(0, 0, 0);">You can also use the frameset and xhtml
077: * attributes
078: * to specify XHTML
079: * Transitional and HTML Frameset.<br>
080: * </p>
081: * <h3 style="color: rgb(0, 0, 0);">Client Side Javascript Functions</h3>
082: * <span style="color: rgb(0, 0, 0);">None.
083: * </span><br style="color: rgb(0, 0, 0);">
084: * <h3 style="color: rgb(0, 0, 0);">Example</h3>
085: * <b style="color: rgb(0, 0, 0);">Example 1: Using the page tag
086: * appropriately in a JSP page:<br>
087: * <br>
088: * </b><code style="color: rgb(0, 0, 0);"><?xml version="1.0"
089: * encoding="UTF-8"?><br>
090: * <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core"
091: * xmlns:h="http://java.sun.com/jsf/html"
092: * xmlns:jsp="http://java.sun.com/JSP/Page"
093: * xmlns:ui="http://www.sun.com/web/ui"><br>
094: * <jsp:directive.page contentType="text/html;charset=ISO-8859-1"
095: * pageEncoding="UTF-8"/><br>
096: * <f:view><br>
097: * <span style="font-weight: bold;"><ui:page></span><br>
098: * <ui:html><br>
099: * <span style="font-weight: bold;">......<br>
100: * <</span>/ui:html><br>
101: * </ui:page><br>
102: * </f:view><br>
103: * </code><b style="color: rgb(0, 0, 0);"><span
104: * style="font-family: monospace;"></span></b>
105: * <p>Auto-generated component class.
106: * Do <strong>NOT</strong> modify; all changes
107: * <strong>will</strong> be lost!</p>
108: */
109:
110: public abstract class PageBase extends
111: javax.faces.component.UIComponentBase {
112:
113: /**
114: * <p>Construct a new <code>PageBase</code>.</p>
115: */
116: public PageBase() {
117: super ();
118: setRendererType("com.sun.rave.web.ui.Page");
119: }
120:
121: /**
122: * <p>Return the identifier of the component family to which this
123: * component belongs. This identifier, in conjunction with the value
124: * of the <code>rendererType</code> property, may be used to select
125: * the appropriate {@link Renderer} for this component instance.</p>
126: */
127: public String getFamily() {
128: return "com.sun.rave.web.ui.Page";
129: }
130:
131: // frame
132: private boolean frame = false;
133: private boolean frame_set = false;
134:
135: /**
136: * <p>Use the frame attribute to
137: * indicate whether the page should render frames. If this attribute is
138: * true, the rendered HTML page includes a </span><code
139: * style="color: rgb(0, 0, 0);"><frameset></code><span
140: * style="color: rgb(0, 0, 0);"> element. If false, the rendered page
141: * uses a </span><code style="color: rgb(0, 0, 0);"><body></code><span
142: * style="color: rgb(0, 0, 0);"> tag. This attribute also
143: * influences the rendering of the <code><!DOCTYPE></code>
144: * declaration. If frameset is true, the <code><!DOCTYPE></code> will
145: * be one of the following,
146: * depending on the setting of xhtml attribute.<br><pre style="color: rgb(0, 0, 0);"><!DOCTYPE html <br> PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"><br><br><!DOCTYPE html <br> PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"<br> "http://www.w3.org/TR/html4/DTD/frameset.dtd"><br></pre></p>
147: */
148: public boolean isFrame() {
149: if (this .frame_set) {
150: return this .frame;
151: }
152: ValueBinding _vb = getValueBinding("frame");
153: if (_vb != null) {
154: Object _result = _vb.getValue(getFacesContext());
155: if (_result == null) {
156: return false;
157: } else {
158: return ((Boolean) _result).booleanValue();
159: }
160: }
161: return false;
162: }
163:
164: /**
165: * <p>Use the frame attribute to
166: * indicate whether the page should render frames. If this attribute is
167: * true, the rendered HTML page includes a </span><code
168: * style="color: rgb(0, 0, 0);"><frameset></code><span
169: * style="color: rgb(0, 0, 0);"> element. If false, the rendered page
170: * uses a </span><code style="color: rgb(0, 0, 0);"><body></code><span
171: * style="color: rgb(0, 0, 0);"> tag. This attribute also
172: * influences the rendering of the <code><!DOCTYPE></code>
173: * declaration. If frameset is true, the <code><!DOCTYPE></code> will
174: * be one of the following,
175: * depending on the setting of xhtml attribute.<br><pre style="color: rgb(0, 0, 0);"><!DOCTYPE html <br> PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"><br><br><!DOCTYPE html <br> PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"<br> "http://www.w3.org/TR/html4/DTD/frameset.dtd"><br></pre></p>
176: * @see #isFrame()
177: */
178: public void setFrame(boolean frame) {
179: this .frame = frame;
180: this .frame_set = true;
181: }
182:
183: // xhtml
184: private boolean xhtml = false;
185: private boolean xhtml_set = false;
186:
187: /**
188: * <p>XHTML transitional page or HTML transitional page. This attribute influences
189: * the rendering of the <code><!DOCTYPE></code> declaration. If xhtml
190: * is true, the <code><!DOCTYPE></code> will be one of the following,
191: * depending on the setting of frameset attribute.<br><pre style="color: rgb(0, 0, 0);"><!DOCTYPE html <br> PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"</pre><pre style="color: rgb(0, 0, 0);"><!DOCTYPE html <br> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></pre></p>
192: */
193: public boolean isXhtml() {
194: if (this .xhtml_set) {
195: return this .xhtml;
196: }
197: ValueBinding _vb = getValueBinding("xhtml");
198: if (_vb != null) {
199: Object _result = _vb.getValue(getFacesContext());
200: if (_result == null) {
201: return false;
202: } else {
203: return ((Boolean) _result).booleanValue();
204: }
205: }
206: return true;
207: }
208:
209: /**
210: * <p>XHTML transitional page or HTML transitional page. This attribute influences
211: * the rendering of the <code><!DOCTYPE></code> declaration. If xhtml
212: * is true, the <code><!DOCTYPE></code> will be one of the following,
213: * depending on the setting of frameset attribute.<br><pre style="color: rgb(0, 0, 0);"><!DOCTYPE html <br> PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"</pre><pre style="color: rgb(0, 0, 0);"><!DOCTYPE html <br> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></pre></p>
214: * @see #isXhtml()
215: */
216: public void setXhtml(boolean xhtml) {
217: this .xhtml = xhtml;
218: this .xhtml_set = true;
219: }
220:
221: /**
222: * <p>Restore the state of this component.</p>
223: */
224: public void restoreState(FacesContext _context, Object _state) {
225: Object _values[] = (Object[]) _state;
226: super .restoreState(_context, _values[0]);
227: this .frame = ((Boolean) _values[1]).booleanValue();
228: this .frame_set = ((Boolean) _values[2]).booleanValue();
229: this .xhtml = ((Boolean) _values[3]).booleanValue();
230: this .xhtml_set = ((Boolean) _values[4]).booleanValue();
231: }
232:
233: /**
234: * <p>Save the state of this component.</p>
235: */
236: public Object saveState(FacesContext _context) {
237: Object _values[] = new Object[5];
238: _values[0] = super .saveState(_context);
239: _values[1] = this .frame ? Boolean.TRUE : Boolean.FALSE;
240: _values[2] = this .frame_set ? Boolean.TRUE : Boolean.FALSE;
241: _values[3] = this .xhtml ? Boolean.TRUE : Boolean.FALSE;
242: _values[4] = this.xhtml_set ? Boolean.TRUE : Boolean.FALSE;
243: return _values;
244: }
245:
246: }
|