/* Copyright (C) 2005-2012, by the President and Fellows of Harvard College. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Dataverse Network - A web application to share, preserve and analyze research data. Developed at the Institute for Quantitative Social Science, Harvard University. Version 3.0. */ /* * DvnInlineHelp.java * * Created on March 29, 2007, 11:13 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package edu.harvard.iq.dvn.core.web.component; import javax.faces.context.FacesContext; import java.io.IOException; import javax.faces.component.UIComponentBase; import javax.faces.context.ResponseWriter; /** * * @author wbossons */ public class DvnInlineHelp extends UIComponentBase implements java.io.Serializable { /** Creates a new instance of DvnInlineHelp */ public DvnInlineHelp() { } public String getFamily() { return null; } public void encodeBegin(FacesContext facescontext) throws IOException { ResponseWriter writer = facescontext.getResponseWriter(); //the link. String linkText = (String)getAttributes().get("linkText"); String cssClass = (String)getAttributes().get("cssClass"); String tooltipText = (String)getAttributes().get("tooltipText"); String eventType = (String)getAttributes().get("eventType"); String heading = (String)getAttributes().get("heading"); writer.startElement("a", this); writer.writeAttribute("id", getClientId(facescontext), null); writer.writeAttribute("name", getClientId(facescontext), null); if (eventType.equals("mouseover")) { writer.writeAttribute("onmouseover", new String("javascript:popupInlineHelp('" + getClientId(facescontext) + "', document.getElementById('" + new String(getClientId(facescontext) + ":hidField") + "').value" + ", '" + heading + "', event);"), null); writer.writeAttribute("onmouseout", new String("javascript:hideInlineHelp();"), null); } else if (eventType.equals("click")) { writer.writeAttribute("title", tooltipText, null); writer.writeAttribute("onclick", new String("javascript:popupInlineHelp('" + getClientId(facescontext) + "', document.getElementById('" + new String(getClientId(facescontext) + ":hidField") + "').value" + ", '" + heading + "', event);"), null); } if (cssClass != null) { writer.writeAttribute("class", cssClass, null); writer.writeText(linkText, null); } else { writer.writeText(linkText, null); } writer.endElement("a"); } public void encodeChildren(FacesContext facescontext) throws IOException { //Nothing to do } public void encodeEnd(FacesContext facescontext) throws IOException { String helpText = (String)getAttributes().get("helpMessage"); ResponseWriter writer = facescontext.getResponseWriter(); writer.startElement("input", this); writer.writeAttribute("type", "hidden", null); writer.writeAttribute("id", new String(getClientId(facescontext) + ":hidField"), null); writer.writeAttribute("name", new String("hid" + getClientId(facescontext)), null); writer.writeAttribute("value", helpText, null); writer.endElement("input"); } }