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 the <code><ui:helpInline></code> tag to display inline help.
051: *
052: * <h3 >HTML Elements and Layout</h3>
053: * The rendered HTML page displays the body content of the
054: * <code><ui:helpInline></code> tag inside of an XHTML compliant
055: * <code><div></code> element. An appropriate style class will be set for
056: * the <code><div></code> element based upon the helpInline type.
057: * <h3 >Client Side Javascript Functions</h3>
058: * None.
059: * <h3 >Examples</h3>
060: * <h4>Example 1: Render page help</h4>
061: * <code><ui:helpInline id="pageHelp" text="This is page inline help." /></code>
062: *
063: * <h4>Example 2: Render field help</h4>
064: * <code><ui:helpInline id="fieldHelp" type="field" text="This is field inline help." /></code>
065: *
066: * <h4>Example 3: Render inline help with an embedded link</h4>
067: * <code><ui:helpInline id="pageHelp" type="field"><br>
068: * <f:verbatim>Enter a password. For more information about passwords </f:verbatim><br>
069: * <ui:imageHyperlink icon="HREF_LINK" id="helpLink" text="click here" /><br>
070: * </ui:helpInline>
071: * <p>Auto-generated component class.
072: * Do <strong>NOT</strong> modify; all changes
073: * <strong>will</strong> be lost!</p>
074: */
075:
076: public abstract class HelpInlineBase extends
077: javax.faces.component.UIOutput {
078:
079: /**
080: * <p>Construct a new <code>HelpInlineBase</code>.</p>
081: */
082: public HelpInlineBase() {
083: super ();
084: setRendererType("com.sun.rave.web.ui.HelpInline");
085: }
086:
087: /**
088: * <p>Return the identifier of the component family to which this
089: * component belongs. This identifier, in conjunction with the value
090: * of the <code>rendererType</code> property, may be used to select
091: * the appropriate {@link Renderer} for this component instance.</p>
092: */
093: public String getFamily() {
094: return "com.sun.rave.web.ui.HelpInline";
095: }
096:
097: /**
098: * <p>Return the <code>ValueBinding</code> stored for the
099: * specified name (if any), respecting any property aliases.</p>
100: *
101: * @param name Name of value binding to retrieve
102: */
103: public ValueBinding getValueBinding(String name) {
104: if (name.equals("text")) {
105: return super .getValueBinding("value");
106: }
107: return super .getValueBinding(name);
108: }
109:
110: /**
111: * <p>Set the <code>ValueBinding</code> stored for the
112: * specified name (if any), respecting any property
113: * aliases.</p>
114: *
115: * @param name Name of value binding to set
116: * @param binding ValueBinding to set, or null to remove
117: */
118: public void setValueBinding(String name, ValueBinding binding) {
119: if (name.equals("text")) {
120: super .setValueBinding("value", binding);
121: return;
122: }
123: super .setValueBinding(name, binding);
124: }
125:
126: // style
127: private String style = null;
128:
129: /**
130: * <p>CSS style(s) to be applied when this component is rendered.</p>
131: */
132: public String getStyle() {
133: if (this .style != null) {
134: return this .style;
135: }
136: ValueBinding _vb = getValueBinding("style");
137: if (_vb != null) {
138: return (String) _vb.getValue(getFacesContext());
139: }
140: return null;
141: }
142:
143: /**
144: * <p>CSS style(s) to be applied when this component is rendered.</p>
145: * @see #getStyle()
146: */
147: public void setStyle(String style) {
148: this .style = style;
149: }
150:
151: // styleClass
152: private String styleClass = null;
153:
154: /**
155: * <p>CSS style class(es) to be applied when this component is rendered.</p>
156: */
157: public String getStyleClass() {
158: if (this .styleClass != null) {
159: return this .styleClass;
160: }
161: ValueBinding _vb = getValueBinding("styleClass");
162: if (_vb != null) {
163: return (String) _vb.getValue(getFacesContext());
164: }
165: return null;
166: }
167:
168: /**
169: * <p>CSS style class(es) to be applied when this component is rendered.</p>
170: * @see #getStyleClass()
171: */
172: public void setStyleClass(String styleClass) {
173: this .styleClass = styleClass;
174: }
175:
176: // text
177: /**
178: * <p>The inline help text to display.</p>
179: */
180: public Object getText() {
181: return getValue();
182: }
183:
184: /**
185: * <p>The inline help text to display.</p>
186: * @see #getText()
187: */
188: public void setText(Object text) {
189: setValue(text);
190: }
191:
192: // type
193: private String type = null;
194:
195: /**
196: * <p>The type of inline help - valid values are "page" or "field". Note that
197: * "page" is the default.</p>
198: */
199: public String getType() {
200: if (this .type != null) {
201: return this .type;
202: }
203: ValueBinding _vb = getValueBinding("type");
204: if (_vb != null) {
205: return (String) _vb.getValue(getFacesContext());
206: }
207: return "page";
208: }
209:
210: /**
211: * <p>The type of inline help - valid values are "page" or "field". Note that
212: * "page" is the default.</p>
213: * @see #getType()
214: */
215: public void setType(String type) {
216: this .type = type;
217: }
218:
219: // visible
220: private boolean visible = false;
221: private boolean visible_set = false;
222:
223: /**
224: * <p>Use the visible attribute to indicate whether the component should be
225: * viewable by the user in the rendered HTML page. If set to false, the
226: * HTML code for the component is present in the page, but the component
227: * is hidden with style attributes. By default, visible is set to true, so
228: * HTML for the component HTML is included and visible to the user. If the
229: * component is not visible, it can still be processed on subsequent form
230: * submissions because the HTML is present.</p>
231: */
232: public boolean isVisible() {
233: if (this .visible_set) {
234: return this .visible;
235: }
236: ValueBinding _vb = getValueBinding("visible");
237: if (_vb != null) {
238: Object _result = _vb.getValue(getFacesContext());
239: if (_result == null) {
240: return false;
241: } else {
242: return ((Boolean) _result).booleanValue();
243: }
244: }
245: return true;
246: }
247:
248: /**
249: * <p>Use the visible attribute to indicate whether the component should be
250: * viewable by the user in the rendered HTML page. If set to false, the
251: * HTML code for the component is present in the page, but the component
252: * is hidden with style attributes. By default, visible is set to true, so
253: * HTML for the component HTML is included and visible to the user. If the
254: * component is not visible, it can still be processed on subsequent form
255: * submissions because the HTML is present.</p>
256: * @see #isVisible()
257: */
258: public void setVisible(boolean visible) {
259: this .visible = visible;
260: this .visible_set = true;
261: }
262:
263: /**
264: * <p>Restore the state of this component.</p>
265: */
266: public void restoreState(FacesContext _context, Object _state) {
267: Object _values[] = (Object[]) _state;
268: super .restoreState(_context, _values[0]);
269: this .style = (String) _values[1];
270: this .styleClass = (String) _values[2];
271: this .type = (String) _values[3];
272: this .visible = ((Boolean) _values[4]).booleanValue();
273: this .visible_set = ((Boolean) _values[5]).booleanValue();
274: }
275:
276: /**
277: * <p>Save the state of this component.</p>
278: */
279: public Object saveState(FacesContext _context) {
280: Object _values[] = new Object[6];
281: _values[0] = super .saveState(_context);
282: _values[1] = this .style;
283: _values[2] = this .styleClass;
284: _values[3] = this .type;
285: _values[4] = this .visible ? Boolean.TRUE : Boolean.FALSE;
286: _values[5] = this.visible_set ? Boolean.TRUE : Boolean.FALSE;
287: return _values;
288: }
289:
290: }
|