Package org.primefaces.component.avatar
Class AvatarRenderer
java.lang.Object
javax.faces.render.Renderer
org.primefaces.renderkit.CoreRenderer
org.primefaces.component.avatar.AvatarRenderer
-
Field Summary
Fields inherited from class javax.faces.render.Renderer
PASSTHROUGH_RENDERER_LOCALNAME_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcalculateLabel(javax.faces.context.FacesContext context, Avatar avatar) Generates a label based on the text if its more than 2 characters.voidencodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) protected voidencodeDefaultContent(javax.faces.context.FacesContext context, Avatar avatar, String label) voidencodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) protected StringgenerateBackgroundColor(Avatar avatar) Generates a dynamic color based on the hash of the label.protected StringgenerateGravatar(javax.faces.context.FacesContext context, Avatar avatar) Generate a Gravatar URL for an email addressed based on API docs.protected voidgenerateMailHash(StringBuilder sb, String email) Converts email address into a hash code for Gravatar API.booleanMethods inherited from class org.primefaces.renderkit.CoreRenderer
buildAjaxRequest, buildAjaxRequest, buildAjaxRequest, buildDomEvent, buildNonAjaxRequest, buildNonAjaxRequest, decodeBehaviors, encodeClientBehaviors, encodeIndexedId, endsWithLenghtUnit, getEventBehaviors, getHighlighter, getIconOnlyButtonText, getResourceRequestPath, getResourceURL, getStyleBuilder, getStyleClassBuilder, getWidgetBuilder, isGrouped, isValueBlank, logDevelopmentWarning, preConfiguredAjaxRequestBuilder, preConfiguredAjaxRequestBuilder, renderAttribute, renderChild, renderChildren, renderDomEvent, renderDomEvents, renderDummyMarkup, renderDynamicPassThruAttributes, renderHiddenInput, renderOnchange, renderOnclick, renderPassThruAttributes, renderPassThruAttributes, renderPassThruAttributes, renderValidationMetadata, shouldRenderAttribute, shouldWriteIdMethods inherited from class javax.faces.render.Renderer
convertClientId, decode, encodeBegin, getConvertedValue
-
Constructor Details
-
AvatarRenderer
public AvatarRenderer()
-
-
Method Details
-
encodeEnd
public void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws IOException - Overrides:
encodeEndin 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:
encodeChildrenin classjavax.faces.render.Renderer- Throws:
IOException
-
getRendersChildren
public boolean getRendersChildren()- Overrides:
getRendersChildrenin classjavax.faces.render.Renderer
-
calculateLabel
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
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
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:
-
generateMailHash
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
-