org.sakaiproject.profile2.tool.components
Class ProfileImageRenderer

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.markup.html.WebComponent
          extended by org.apache.wicket.markup.html.image.Image
              extended by org.sakaiproject.profile2.tool.components.ProfileImageRenderer
All Implemented Interfaces:
Serializable, org.apache.wicket.IClusterable, org.apache.wicket.IConverterLocator, org.apache.wicket.IRequestListener, org.apache.wicket.IResourceListener

public class ProfileImageRenderer
extends org.apache.wicket.markup.html.image.Image
implements org.apache.wicket.IResourceListener

Profile2 ProfileImageRenderer component.

This component should be used whenever you want to render a user's profile image. Choose the most appropriate constructor for your needs and situation.

Note that in order to request another user's image you should supply either a full Person object containing the Privacy settings, or the ProfilePrivacy settings directly. If you do not have this information you can pass null as the ProfilePrivacy attribute and it will be consulted for you.

If you do not provide a ProfilePreferences object (or Person object containing this info), it will be looked up.

If you do not provide the size or cache settings, they will be defaults (size=main, cache=true).

In short, always provide all information (and preferably a full Person object)

Author:
Steve Swinsburg (steve.swinsburg@gmail.com)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
org.apache.wicket.Component.ComponentModelChange, org.apache.wicket.Component.EnabledChange, org.apache.wicket.Component.IVisitor<T extends org.apache.wicket.Component>, org.apache.wicket.Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Fields inherited from interface org.apache.wicket.IResourceListener
INTERFACE
 
Constructor Summary
ProfileImageRenderer(String id, Person person)
          Full constructor that takes a Person object instead of split data.
ProfileImageRenderer(String id, Person person, int size, boolean cache)
          Full constructor that takes a Person object and allows control over the size and cache settings.
ProfileImageRenderer(String id, String userUuid)
          Minimal constructor.
ProfileImageRenderer(String id, String userUuid, ProfilePreferences prefs)
          Minimal constructor.
ProfileImageRenderer(String id, String userUuid, ProfilePreferences prefs, int size, boolean cache)
          Minimal constructor.
ProfileImageRenderer(String id, String userUuid, ProfilePreferences prefs, ProfilePrivacy privacy)
          Minimal constructor.
ProfileImageRenderer(String id, String userUuid, ProfilePreferences prefs, ProfilePrivacy privacy, int size, boolean cache)
          Full constructor where each item is explicitly provided.
 
Method Summary
 void onComponentTag(org.apache.wicket.markup.ComponentTag tag)
          Render the tag
 void onResourceRequested()
           
 
Methods inherited from class org.apache.wicket.markup.html.image.Image
getImageResource, getImageResourceReference, getStatelessHint, initModel, onComponentTagBody, setDefaultModel, setImageResource, setImageResourceReference, setImageResourceReference
 
Methods inherited from class org.apache.wicket.markup.html.WebComponent
onRender
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onConfigure, onDetach, onEndRequest, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMarkupStream, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, toString, toString, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            String userUuid)
Minimal constructor. Use this for when requesting your own image and only if you don't have access to the ProfilePreferences object. Will lookup ProfilePreferences and uses defaults for size(main) and cache(true).

Parameters:
id - markup ID
userUuid - uuid of the user to retrieve the image for

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            String userUuid,
                            ProfilePreferences prefs)
Minimal constructor. Use this for when requesting your own image. Uses defaults for size(main) and cache(true).

Parameters:
id - markup ID
userUuid - uuid of the user to retrieve the image for
prefs - ProfilePreferences object for the user

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            String userUuid,
                            ProfilePreferences prefs,
                            int size,
                            boolean cache)
Minimal constructor. Use this for when requesting your own image and want to control the size and cache setting.

Parameters:
id - markup ID
userUuid - uuid of the user to retrieve the image for.
prefs - ProfilePreferences object for the user.
size - image size: 1 for main, 2 for thumbnail.
cache - if this image is allowed to be cached by the browser or not. If having issues with dynamic images sticking from AJAX updates, set this to false to ensure the image is updated every request.

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            String userUuid,
                            ProfilePreferences prefs,
                            ProfilePrivacy privacy)
Minimal constructor. Use this when requesting someone else's image. Uses defaults for size and cache.

Parameters:
id - markup ID
userUuid - uuid of the user to retrieve the image for
prefs - ProfilePreferences object for the user
privacy - ProfilePrivacy object for the user

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            String userUuid,
                            ProfilePreferences prefs,
                            ProfilePrivacy privacy,
                            int size,
                            boolean cache)
Full constructor where each item is explicitly provided.

Parameters:
id - markup ID
userUuid - uuid of the user to retrieve the image for
prefs - ProfilePreferences object for the user
privacy - ProfilePrivacy object for the user
size - image size: 1 for main, 2 for thumbnail.
cache - if this image is allowed to be cached by the browser or not. If having issues with dynamic images sticking from AJAX updates, set this to false to ensure the image is updated every request.

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            Person person)
Full constructor that takes a Person object instead of split data. Defaults will be used for size(main) and cache(true).

Parameters:
id - markup ID
person - Person object for the user containing all data

ProfileImageRenderer

public ProfileImageRenderer(String id,
                            Person person,
                            int size,
                            boolean cache)
Full constructor that takes a Person object and allows control over the size and cache settings.

Parameters:
id - markup ID
person - Person object for the user containing all data
size - image size: 1 for main, 2 for thumbnail.
cache - if this image is allowed to be cached by the browser or not. If having issues with dynamic images sticking from AJAX updates, set this to false to ensure the image is updated every request.
Method Detail

onResourceRequested

public void onResourceRequested()
Specified by:
onResourceRequested in interface org.apache.wicket.IResourceListener
Overrides:
onResourceRequested in class org.apache.wicket.markup.html.image.Image
See Also:
IResourceListener.onResourceRequested()

onComponentTag

public void onComponentTag(org.apache.wicket.markup.ComponentTag tag)
Render the tag

Overrides:
onComponentTag in class org.apache.wicket.markup.html.image.Image


Copyright © 2008-2012 The Sakai Foundation. All Rights Reserved.