/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { Node } from "../../types/javax/jcr/Node"; import type { String } from "../../types/java/lang/String"; /** * UserFieldRenderer is a stateful utility interface for rendering user field values for user identities. * *
* An instance of the Sitevision class implementing this interface can be obtained via {@link senselogic.sitevision.api.Utils#getUserFieldRenderer()}.
* See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the Utils interface.
*
* Using the UserFieldRenderer is pretty straightforward, if you remember that it is stateful and that the previously loaded * user identity node will be cleared whenever you try to load a new one. Conceptually you would typically use it like this: *
** You can then re-use the UserFieldRenderer for another user identity until you are done. Something like: *
*
* Example of how this strategy could be implemented in Velocity:
* (You want to do a simple listing of the user fields "Namn" and "E-postadress" for some user identities or users in $myList)
*
* ## Get UserFieldRenderer
* #set ($userFieldRenderer = $sitevisionUtils.userFieldRenderer)
*
* ## Ensure at least one of the fields actually exist
* #if ($userFieldRenderer.isValidFieldName('Namn') || $userFieldRenderer.isValidFieldName('E-postadress'))
* ## Iterate through the list and render fields for all valid nodes
* <ul class="sv-no-list-style">
* #foreach ($item in $myList)
* ## Check if this node can be rendered
* #if ($userFieldRenderer.isRenderable($item))
* ## Update the renderer and render
* $userFieldRenderer.update($item)
* <li>
* $userFieldRenderer.render('Namn')
* $userFieldRenderer.render('E-postadress')
* </li>
* #end
* #end
* </ul>
* #end
*
*
* * Important rendering note! When rendering a user field value, you must specify the name * of the user field. See {@link #isValidFieldName(String)} for more information about how names are matched to user fields. *
* @author Magnus Lövgren * @since Sitevision 3.5.3 */ export interface UserFieldRenderer { /** * Updates the renderer with a new user identity node. * *
* If aUserIdentity is not a renderable node, the argument will be considered as null, i.e.
* the renderer will not have any renderable node in subsequent render execution.
*
true if a renderable node is loaded, false if not.
*/
isLoaded(): boolean;
/**
* Helper method to check if a certain node can be rendered.
*
* * Nodes with the following primary node types are potentially renderable: *
*sv:userIdentitysv: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 extractedtrue if aNode is supported by this renderer, false if not
*/
isRenderable(aNode: Node): boolean;
/**
* Helper method to check if a named user field is available.
*
* * An important note about field names and user field lookup! A specific user field can be found * via multiple names: *
** First found match is used! *
** This is a convenience to make user fields easier to find, but beware of colliding names! For instance, * if field A has Ldap name "X" and field B has UI name "X" - field B will be used. *
* @param aUserFieldName the name of the user field * @returntrue if current site has a user field that can be found via aUserFieldName, false if not
*/
isValidFieldName(aUserFieldName: String | string): boolean;
/**
* Returns the value as html for a named user field for currently loaded user identity.
*
* * The rendered output of the user field value is handled as: *
** Note! The result of this method is equivalent with calling {@link #getPlainUserFieldValueAsHtml(String)} with the * result of the {@link #renderPlain(String)} method, but this method is more efficient and should always be preferred. *
* @param aUserFieldName the name of the user field, see: {@link #isValidFieldName(String)} * @return a html string, ready to print out on a page. Might be empty but nevernull.
*/
render(aUserFieldName: String | string): string;
/**
* Returns the value as plain text for a named user field for currently loaded user identity.
*
* * Note! The rendered output is plain text and must be escaped if it should be part of the html output of a page! *
* @param aUserFieldName the name of the user field, see: {@link #isValidFieldName(String)} * @return a plain string. Might be empty but nevernull.
* @since Sitevision 3.6
* @see #render(String)
*/
renderPlain(aUserFieldName: String | string): string;
/**
* Returns a plain text user field value as html.
*
* * Note! This method is stateless, i.e. you don't have to have a user identity loaded to call this method. * Typically you would always use the {@link #render(String)} whenever possible. This method should only be used when you have a plain * text user field value, but no user identity (e.g. in large search results where you want to avoid loading lots of user identity objects). *
** The rendered output of the plain text user field value is handled as: *
*null.
* @since Sitevision 3.6
*/
getPlainUserFieldValueAsHtml(aPlainUserFieldValue: String | string): string;
}
declare namespace UserFieldRenderer {}
declare var userFieldRenderer: UserFieldRenderer;
export default userFieldRenderer;