Package org.primefaces.component.avatar
Class AvatarRenderer
- java.lang.Object
-
- javax.faces.render.Renderer
-
- org.primefaces.renderkit.CoreRenderer
-
- org.primefaces.component.avatar.AvatarRenderer
-
public class AvatarRenderer extends CoreRenderer
-
-
Constructor Summary
Constructors Constructor Description AvatarRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
calculateLabel(javax.faces.context.FacesContext context, Avatar avatar)
Generates a label based on the text if its more than 2 characters.void
encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
protected void
encodeDefaultContent(javax.faces.context.FacesContext context, Avatar avatar, String label)
void
encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
protected String
generateBackgroundColor(Avatar avatar)
Generates a dynamic color based on the hash of the label.protected String
generateGravatar(javax.faces.context.FacesContext context, Avatar avatar)
Generate a Gravatar URL for an email addressed based on API docs.protected void
generateMailHash(StringBuilder sb, String email)
Converts email address into a hash code for Gravatar API.boolean
getRendersChildren()
-
Methods inherited from class org.primefaces.renderkit.CoreRenderer
buildAjaxRequest, buildAjaxRequest, buildAjaxRequest, buildDomEvent, buildNonAjaxRequest, buildNonAjaxRequest, decodeBehaviors, encodeClientBehaviors, endsWithLenghtUnit, getEventBehaviors, getHighlighter, getResourceRequestPath, getResourceURL, getStyleBuilder, getStyleClassBuilder, getWidgetBuilder, isGrouped, isValueBlank, preConfiguredAjaxRequestBuilder, preConfiguredAjaxRequestBuilder, renderChild, renderChildren, renderDomEvent, renderDomEvents, renderDummyMarkup, renderDynamicPassThruAttributes, renderHiddenInput, renderOnchange, renderOnclick, renderPassThruAttributes, renderPassThruAttributes, renderPassThruAttributes, renderValidationMetadata, shouldRenderAttribute, shouldWriteId
-
-
-
-
Method Detail
-
encodeEnd
public void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws IOException
- Overrides:
encodeEnd
in classjavax.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 classjavax.faces.render.Renderer
- Throws:
IOException
-
getRendersChildren
public boolean getRendersChildren()
- Overrides:
getRendersChildren
in classjavax.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 Faceavatar
- the Avatar to create a Gravatar for- Returns:
- the URL to retrieve the Gravatar image
- See Also:
- Image Requests
-
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 toemail
- the email to encode- Throws:
NoSuchAlgorithmException
- if hash can't be encoded
-
-