Created
May 1, 2012 14:58
-
-
Save lfryc/2568559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.richfaces.bootstrap.renderkit; | |
import java.io.IOException; | |
import javax.faces.component.UIComponent; | |
import javax.faces.context.FacesContext; | |
import javax.faces.context.ResponseWriter; | |
import org.richfaces.bootstrap.component.AbstractIcon; | |
import org.richfaces.bootstrap.renderkit.IconRendererBase; | |
public class IconRenderer extends IconRendererBase { | |
private static String convertToString(Object object) | |
{ | |
return object != null ? object.toString() : ""; | |
} | |
@Override | |
public void encodeEnd(FacesContext facesContext, UIComponent component) | |
throws IOException | |
{ | |
ResponseWriter responseWriter = facesContext.getResponseWriter(); | |
String clientId = component.getClientId(facesContext); | |
AbstractIcon icon = this.castComponent(component); | |
responseWriter.startElement("i", component); | |
{ | |
String value = "icon-" + convertToString(icon.getValue()) + " " + convertToString((((icon.getColor() != null) && (!icon.getColor().equals(""))) ? "icon-".concat(icon.getColor()) : "")); | |
if(null != value && | |
value.length()>0 | |
) { | |
responseWriter.writeAttribute("class",value,null); | |
} | |
} | |
{ | |
String value = clientId; | |
if(null != value && | |
value.length()>0 | |
) { | |
responseWriter.writeAttribute("id",value,null); | |
} | |
} | |
responseWriter.endElement("i"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment