Copyright© 2008-2022 Sitevision AB, all rights reserved.
@Requireable(value="BuddyIconRenderer") public interface BuddyIconRenderer
An instance of the Sitevision class implementing this interface can be obtained via Utils.getBuddyIconRenderer()
.
See Utils
for how to obtain an instance of the Utils
interface.
BuddyIconRenderer has few attributes:
null
.
BuddyIconSize.SMALL
. Note that image size
settings are followed with best effort. Images will never be upscaled.
true
.
Using the BuddyIconRenderer is pretty straightforward, if you remember that it is stateful and that the previously loaded buddy icon node will be cleared whenever you try to load a new one. Conceptually you would typically use it like this:
When you have rendered once, you can re-use the BuddyIconRenderer until you are done. Something like:
Example of how this strategy could be implemented in Velocity:
(You want to do a simple listing of buddy icons for some collaboration groups, collaboration group pages, user identities or users)
## Get BuddyIconRenderer
#set ($buddyIconRenderer = $sitevisionUtils.buddyIconRenderer)
## Iterate through the list of nodes and render a buddy icon for all supported nodes
<ul class="sv-no-list-style">
#foreach ($item in $items)
## Check if this node can be rendered as a buddy icon
#if ($buddyIconRenderer.isRenderable($item))
## Update the renderer and render
$buddyIconRenderer.update($item)
<li>
$buddyIconRenderer.render()
</li>
#end
#end
</ul>
Modifier and Type | Interface and Description |
---|---|
static interface |
BuddyIconRenderer.BuddyIconInfo
Basic render information about current buddy icon of a BuddyIconRenderer.
|
static class |
BuddyIconRenderer.BuddyIconSize
The size of the icons rendered by the BuddyIconRenderer.
|
Modifier and Type | Method and Description |
---|---|
void |
clearUseLinkBuddyIcon()
Utility method for executing
setLinkBuddyIcon(false) |
void |
forceUseLargeBuddyIconSize()
Utility method for executing
setBuddyIconSize(BuddyIconSize.LARGE) |
void |
forceUseLinkBuddyIcon()
Utility method for executing
setLinkBuddyIcon(true) |
void |
forceUseSmallBuddyIconSize()
Utility method for executing
setBuddyIconSize(BuddyIconSize.SMALL) |
void |
forceUseXLargeBuddyIconSize()
Utility method for executing
setBuddyIconSize(BuddyIconSize.X_LARGE) |
BuddyIconRenderer.BuddyIconInfo |
getBuddyIconInfo()
BuddyIconInfo for current state.
|
boolean |
isLoaded()
Whether or not this renderer contains a node that can be rendered.
|
boolean |
isRenderable(Node aNode)
Helper method to check if a certain node can be rendered as a buddy icon.
|
String |
render()
Builds a html string based on current state.
|
void |
setBuddyIconSize(BuddyIconRenderer.BuddyIconSize aBuddyIconSize)
Sets the size for rendered buddy icons.
|
void |
setLinkBuddyIcon(boolean aLinkBuddyIcon)
Whether or not rendered buddy icons should be linked.
|
void |
update(Node aBuddyIconNode)
Updates the renderer with a new buddy icon supported node.
|
void setBuddyIconSize(BuddyIconRenderer.BuddyIconSize aBuddyIconSize)
Default is BuddyIconSize.SMALL
aBuddyIconSize
- the icon sizevoid forceUseSmallBuddyIconSize()
setBuddyIconSize(BuddyIconSize.SMALL)
void forceUseLargeBuddyIconSize()
setBuddyIconSize(BuddyIconSize.LARGE)
void forceUseXLargeBuddyIconSize()
setBuddyIconSize(BuddyIconSize.X_LARGE)
setBuddyIconSize(senselogic.sitevision.api.render.BuddyIconRenderer.BuddyIconSize)
,
BuddyIconRenderer.BuddyIconSize.X_LARGE
void setLinkBuddyIcon(boolean aLinkBuddyIcon)
Default is true
aLinkBuddyIcon
- Whether or not buddy icons should be linked.void clearUseLinkBuddyIcon()
setLinkBuddyIcon(false)
setLinkBuddyIcon(boolean)
void forceUseLinkBuddyIcon()
setLinkBuddyIcon(true)
setLinkBuddyIcon(boolean)
void update(Node aBuddyIconNode)
If aBuddyIconNode
is not a type that can be represented by a buddy icon, the argument will be considered as null
,
i.e. the renderer will not have any renderable node in subsequent render execution.
aBuddyIconNode
- a node that can be rendered as a buddy icon.boolean isLoaded()
true
if a renderable node is loaded, false
if not.boolean isRenderable(Node aNode)
Nodes with the following primary node types are potentially renderable:
sv:userIdentity
sv:user
(non-anonymous) » will be renderable if a sv:userIdentity can be extractedsv:simpleUser
» will be renderable if a sv:userIdentity can be extractedsv:systemUser
» will be renderable if a sv:userIdentity can be extractedsv:collaborationGroup
sv:collaborationGroupPage
» will be renderable if a sv:collaborationGroup can be extractedaNode
- the node to checktrue
if aNode
is supported by this renderer, false
if notBuddyIconRenderer.BuddyIconInfo getBuddyIconInfo()
The data this method provides is used by the render()
method.
The intent of this method is to facilitate custom buddy icon rendering solutions.
See BuddyIconRenderer.BuddyIconInfo
for such example.
Note! Returned BuddyIconInfo object is never null but its uri
will potentially be null and its
width
/height
might be zero.
Typically when this renderer has no valid/renderable node loaded, see isLoaded()
.
String render()
null
.Sitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.