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.renderer;
042:
043: import com.sun.rave.web.ui.util.ConversionUtilities;
044: import java.io.IOException;
045:
046: import javax.faces.context.FacesContext;
047: import javax.faces.context.ResponseWriter;
048: import javax.faces.component.UIComponent;
049:
050: import com.sun.rave.web.ui.component.HelpInline;
051: import com.sun.rave.web.ui.theme.Theme;
052: import com.sun.rave.web.ui.theme.ThemeStyles;
053: import com.sun.rave.web.ui.util.ThemeUtilities;
054: import com.sun.rave.web.ui.util.RenderingUtilities;
055:
056: /**
057: * Renders an instance of the {@link HelpInline} component.
058: *
059: * @author Sean Comerford
060: */
061: public class HelpInlineRenderer extends AbstractRenderer {
062:
063: /** Creates a new instance of HelpInlineRenderer */
064: public HelpInlineRenderer() {
065: }
066:
067: /**
068: * Render the start of the HelpInline component.
069: *
070: * @param context The current FacesContext
071: * @param component The ImageComponent object to use
072: * @param writer The current ResponseWriter
073: *
074: * @exception IOException if an input/output error occurss
075: */
076: protected void renderStart(FacesContext context,
077: UIComponent component, ResponseWriter writer)
078: throws IOException {
079: // render start of HelpInline
080: HelpInline help = (HelpInline) component;
081: Theme theme = ThemeUtilities.getTheme(context);
082:
083: writer.startElement("div", help);
084:
085: String style = null;
086:
087: if (help.getType().equals("page")) {
088: style = theme.getStyleClass(ThemeStyles.HELP_PAGE_TEXT);
089: } else {
090: style = theme.getStyleClass(ThemeStyles.HELP_FIELD_TEXT);
091: }
092:
093: addCoreAttributes(context, help, writer, style);
094:
095: // <RAVE>
096: // String text = help.getText();
097: String text = ConversionUtilities.convertValueToString(help,
098: help.getText());
099: // </RAVE>
100:
101: if (text != null) {
102: writer.write(text);
103: writer.write(" ");
104: }
105: }
106:
107: /**
108: * Render the end of the HelpInline component.
109: *
110: * @param context The current FacesContext
111: * @param component The ImageComponent object to use
112: * @param writer The current ResponseWriter
113: *
114: * @exception IOException if an input/output error occurss
115: */
116: protected void renderEnd(FacesContext context,
117: UIComponent component, ResponseWriter writer)
118: throws IOException {
119: writer.endElement("div");
120: }
121: }
|