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
051: * style="color: rgb(0, 0, 0);"><span
052: * style="text-decoration: line-through;"></span>Use
053: * the <code>ui:markup </code>tag
054: * to insert any type of XML markup
055: * in the rendered HTML page. The <code>ui:markup</code>
056: * tag allows you to insert HTML
057: * elements into the JSP page where HTML is not permitted inside a JSF
058: * tag. <br>
059: * </p>
060: * <h3 style="color: rgb(0, 0, 0);">Configuring
061: * the markup tag <br>
062: * </h3>
063: * <p style="color: rgb(0, 0, 0);">Use
064: * the <code>tag</code>
065: * attribute to specify the type of
066: * HTML element to insert. For instance, to insert a <code><p></code>
067: * tag, set the attribute to <code>tag="p"</code>
068: * in the <code>ui:markup</code>
069: * tag. Note that you do not
070: * include the angle brackets.</p>
071: * <p style="color: rgb(0, 0, 0);">If
072: * the HTML element you are
073: * inserting is a singleton element, you must specify the <code>singleton</code>
074: * attribute. The singleton attribute causes the trailing<code>
075: * /></code>
076: * to be generated in the rendered HTML. For example, the <code><br></code>
077: * element is a singleton element, which must be rendered as <code><br
078: * /> </code>to be XHTML
079: * compliant.</p>
080: * <p style="color: rgb(0, 0, 0);">If
081: * you want to specify
082: * additional HTML attributes for the element you are inserting, use the <code>extraAttributes</code>
083: * attribute. <br>
084: * </p>
085: * <h3 style="color: rgb(0, 0, 0);">HTML
086: * Elements and Layout</h3>
087: * <span style="color: rgb(0, 0, 0);">The
088: * rendered HTML page includes
089: * the HTML element that was specified in the </span><code
090: * style="color: rgb(0, 0, 0);">ui:markup</code><span
091: * style="color: rgb(0, 0, 0);"> tag's </span><code
092: * style="color: rgb(0, 0, 0);">tag</code><span
093: * style="color: rgb(0, 0, 0);"> attribute, along with
094: * any HTML
095: * attributes that were included in the <code>extraAttributes</code>
096: * attribute.<br>
097: * </span>
098: * <h3 style="color: rgb(0, 0, 0);">Theme
099: * Identifiers<br>
100: * </h3>
101: * <p style="color: rgb(0, 0, 0);">None.</p>
102: * <h3 style="color: rgb(0, 0, 0);">Client
103: * Side Javascript
104: * Functions </h3>
105: * <span style="color: rgb(0, 0, 0);">None.</span><br
106: * style="color: rgb(0, 0, 0);">
107: * <h3 style="color: rgb(0, 0, 0);">Examples</h3>
108: * <span style="color: rgb(0, 0, 0);"></span>
109: * <h4 style="color: rgb(0, 0, 0);">Example
110: * 1: Insert a
111: * singleton element <br>
112: * </h4>
113: * <pre style="color: rgb(0, 0, 0);"><code> <ui:markup tag="br" singleton="true" /></code><code><br></code></pre>
114: * <p style="color: rgb(0, 0, 0);">This
115: * generates <code><br
116: * /></code>.</p>
117: * <code style="color: rgb(0, 0, 0);"></code>
118: * <h4 style="color: rgb(0, 0, 0);">Example
119: * 2: Insert a <code><div></code>
120: * element with a style attribute <br>
121: * </h4>
122: * <code style="color: rgb(0, 0, 0);"></code><code
123: * style="color: rgb(0, 0, 0);">
124: * <ui:markup
125: * tag="div"
126: * style="color:blue" /> <br>
127: * </code>
128: * <p style="color: rgb(0, 0, 0);">This
129: * generates <code><div
130: * style="color:blue" ></code></p>
131: * <code style="color: rgb(0, 0, 0);"></code>
132: * <h4 style="color: rgb(0, 0, 0);">Example
133: * 3: Insert a <code><h3></code>
134: * with HTML attributes<br>
135: * </h4>
136: * <pre style="color: rgb(0, 0, 0);"><code> </code><code><ui:markup tag="h3" extraAttributes="onclick='alert(&quot;foobar&quot;);'" ><br> <ui:staticText text="Example" /><br> </ui:markup></code></pre>
137: * <code style="color: rgb(0, 0, 0);"></code><span
138: * style="color: rgb(0, 0, 0);">This generates a
139: * level 3 head titled Example that
140: * will display the alert with "foobar" in it when clicked.</span>
141: * <p>Auto-generated component class.
142: * Do <strong>NOT</strong> modify; all changes
143: * <strong>will</strong> be lost!</p>
144: */
145:
146: public abstract class MarkupBase extends
147: javax.faces.component.UIComponentBase {
148:
149: /**
150: * <p>Construct a new <code>MarkupBase</code>.</p>
151: */
152: public MarkupBase() {
153: super ();
154: setRendererType("com.sun.rave.web.ui.Markup");
155: }
156:
157: /**
158: * <p>Return the identifier of the component family to which this
159: * component belongs. This identifier, in conjunction with the value
160: * of the <code>rendererType</code> property, may be used to select
161: * the appropriate {@link Renderer} for this component instance.</p>
162: */
163: public String getFamily() {
164: return "com.sun.rave.web.ui.Markup";
165: }
166:
167: // extraAttributes
168: private String extraAttributes = null;
169:
170: /**
171: * <p>Add the rest of the attribute name="value" type pairs inside this
172: * attribute. The inserted attributes will need to be escaped.</p>
173: */
174: public String getExtraAttributes() {
175: if (this .extraAttributes != null) {
176: return this .extraAttributes;
177: }
178: ValueBinding _vb = getValueBinding("extraAttributes");
179: if (_vb != null) {
180: return (String) _vb.getValue(getFacesContext());
181: }
182: return null;
183: }
184:
185: /**
186: * <p>Add the rest of the attribute name="value" type pairs inside this
187: * attribute. The inserted attributes will need to be escaped.</p>
188: * @see #getExtraAttributes()
189: */
190: public void setExtraAttributes(String extraAttributes) {
191: this .extraAttributes = extraAttributes;
192: }
193:
194: // singleton
195: private boolean singleton = false;
196: private boolean singleton_set = false;
197:
198: /**
199: * <p>Flag indicating that tag is a singleton tag and that it should end with
200: * a trailing /</p>
201: */
202: public boolean isSingleton() {
203: if (this .singleton_set) {
204: return this .singleton;
205: }
206: ValueBinding _vb = getValueBinding("singleton");
207: if (_vb != null) {
208: Object _result = _vb.getValue(getFacesContext());
209: if (_result == null) {
210: return false;
211: } else {
212: return ((Boolean) _result).booleanValue();
213: }
214: }
215: return false;
216: }
217:
218: /**
219: * <p>Flag indicating that tag is a singleton tag and that it should end with
220: * a trailing /</p>
221: * @see #isSingleton()
222: */
223: public void setSingleton(boolean singleton) {
224: this .singleton = singleton;
225: this .singleton_set = true;
226: }
227:
228: // style
229: private String style = null;
230:
231: /**
232: * <p>CSS style(s) to be applied when this component is rendered.</p>
233: */
234: public String getStyle() {
235: if (this .style != null) {
236: return this .style;
237: }
238: ValueBinding _vb = getValueBinding("style");
239: if (_vb != null) {
240: return (String) _vb.getValue(getFacesContext());
241: }
242: return null;
243: }
244:
245: /**
246: * <p>CSS style(s) to be applied when this component is rendered.</p>
247: * @see #getStyle()
248: */
249: public void setStyle(String style) {
250: this .style = style;
251: }
252:
253: // styleClass
254: private String styleClass = null;
255:
256: /**
257: * <p>CSS style class(es) to be applied when this component is rendered.</p>
258: */
259: public String getStyleClass() {
260: if (this .styleClass != null) {
261: return this .styleClass;
262: }
263: ValueBinding _vb = getValueBinding("styleClass");
264: if (_vb != null) {
265: return (String) _vb.getValue(getFacesContext());
266: }
267: return null;
268: }
269:
270: /**
271: * <p>CSS style class(es) to be applied when this component is rendered.</p>
272: * @see #getStyleClass()
273: */
274: public void setStyleClass(String styleClass) {
275: this .styleClass = styleClass;
276: }
277:
278: // tag
279: private String tag = null;
280:
281: /**
282: * <p>Name of the HTML element to render.</p>
283: */
284: public String getTag() {
285: if (this .tag != null) {
286: return this .tag;
287: }
288: ValueBinding _vb = getValueBinding("tag");
289: if (_vb != null) {
290: return (String) _vb.getValue(getFacesContext());
291: }
292: return null;
293: }
294:
295: /**
296: * <p>Name of the HTML element to render.</p>
297: * @see #getTag()
298: */
299: public void setTag(String tag) {
300: this .tag = tag;
301: }
302:
303: /**
304: * <p>Restore the state of this component.</p>
305: */
306: public void restoreState(FacesContext _context, Object _state) {
307: Object _values[] = (Object[]) _state;
308: super .restoreState(_context, _values[0]);
309: this .extraAttributes = (String) _values[1];
310: this .singleton = ((Boolean) _values[2]).booleanValue();
311: this .singleton_set = ((Boolean) _values[3]).booleanValue();
312: this .style = (String) _values[4];
313: this .styleClass = (String) _values[5];
314: this .tag = (String) _values[6];
315: }
316:
317: /**
318: * <p>Save the state of this component.</p>
319: */
320: public Object saveState(FacesContext _context) {
321: Object _values[] = new Object[7];
322: _values[0] = super .saveState(_context);
323: _values[1] = this .extraAttributes;
324: _values[2] = this .singleton ? Boolean.TRUE : Boolean.FALSE;
325: _values[3] = this .singleton_set ? Boolean.TRUE : Boolean.FALSE;
326: _values[4] = this .style;
327: _values[5] = this .styleClass;
328: _values[6] = this.tag;
329: return _values;
330: }
331:
332: }
|