Class AvatarRenderer

java.lang.Object
javax.faces.render.Renderer
org.primefaces.renderkit.CoreRenderer
org.primefaces.component.avatar.AvatarRenderer

public class AvatarRenderer extends CoreRenderer
  • Constructor Details

    • AvatarRenderer

      public AvatarRenderer()
  • Method Details

    • encodeEnd

      public void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws IOException
      Overrides:
      encodeEnd in class javax.faces.render.Renderer
      Throws:
      IOException
    • encodeDefaultContent

      protected void encodeDefaultContent(javax.faces.context.FacesContext context, Avatar avatar, String label) throws IOException
      Throws:
      IOException
    • encodeChildren

      public void encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws IOException
      Overrides:
      encodeChildren in class javax.faces.render.Renderer
      Throws:
      IOException
    • getRendersChildren

      public boolean getRendersChildren()
      Overrides:
      getRendersChildren in class javax.faces.render.Renderer
    • calculateLabel

      protected String calculateLabel(javax.faces.context.FacesContext context, Avatar avatar)
      Generates a label based on the text if its more than 2 characters. Example: PrimeFaces Rocks = PR
      Parameters:
      avatar - the Avatar component
      Returns:
      the calculated label text.
    • generateBackgroundColor

      protected String generateBackgroundColor(Avatar avatar)
      Generates a dynamic color based on the hash of the label.
      Parameters:
      avatar - to generate the color for
      Returns:
      the new color and background color styles
    • generateGravatar

      protected String generateGravatar(javax.faces.context.FacesContext context, Avatar avatar)
      Generate a Gravatar URL for an email addressed based on API docs.
      Parameters:
      context - the Face
      avatar - the Avatar to create a Gravatar for
      Returns:
      the URL to retrieve the Gravatar image
      See Also:
    • generateMailHash

      protected void generateMailHash(StringBuilder sb, String email) throws NoSuchAlgorithmException
      Converts email address into a hash code for Gravatar API.
      Parameters:
      sb - the Stringbuilder to add the email address to
      email - the email to encode
      Throws:
      NoSuchAlgorithmException - if hash can't be encoded