Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lfryc
Created May 1, 2012 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lfryc/2568559 to your computer and use it in GitHub Desktop.
Save lfryc/2568559 to your computer and use it in GitHub Desktop.
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