Copyright© 2008-2018 SiteVision AB, all rights reserved.
@Requireable(value="PortletContextUtil") public interface PortletContextUtil extends VelocityAccess.PortletContextUtilConstants
Contains methods for retrieving information about present portlet execution context.
An instance of the SiteVision class implementing this interface can be obtained via
Utils.getPortletContextUtil()
.
See Utils
for how to obtain an instance of the Utils
interface.
Modifier and Type | Field and Description |
---|---|
static int |
OFFLINE_VERSION
Deprecated.
|
static int |
ONLINE_VERSION
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
java.util.Locale |
getCurrentLocale()
Gets current Locale.
|
Node |
getCurrentModuleElement()
Gets current module element (module element draft or module element).
|
Node |
getCurrentPage()
Gets current page (i.e. the page node for the currently executing portlet).
|
Node |
getCurrentPortlet()
Gets current portlet.
|
Node |
getCurrentUser()
Gets current user.
|
Node |
getCurrentUserIdentity()
Gets current user identity.
|
int |
getCurrentVersion()
Deprecated.
|
String |
getPortletNamespace(String aPrefix)
Gets a unique namespace for the specific portlet that is rendering.
|
getOFFLINE_VERSION, getONLINE_VERSION
@Deprecated static final int OFFLINE_VERSION
VersionUtil.OFFLINE_VERSION
@Deprecated static final int ONLINE_VERSION
VersionUtil.ONLINE_VERSION
Node getCurrentPage()
Node
, or null
if indeterminable (i.e. this method is not called from within a portlet or
current portlet is not bound to any page)Node getCurrentPortlet()
Node
, or null
if indeterminable (i.e. this method is not called from within a portlet)Node getCurrentModuleElement()
Node
, or null
if indeterminable
(i.e. this method is not called from within a module element)java.util.Locale getCurrentLocale()
Locale
, or default Locale
if indeterminableNodeResolverUtil.getLocaleResolver()
Node getCurrentUser()
Node
, or null
if indeterminableNode getCurrentUserIdentity()
Node
, or null
if indeterminable@Deprecated int getCurrentVersion()
VersionUtil.getCurrentVersion()
VersionUtil.OFFLINE_VERSION
, or
VersionUtil.ONLINE_VERSION
String getPortletNamespace(String aPrefix)
The namespace is based on the prefix (aPrefix) and the current portlet's id. If you have two portlets of same type on the same page, the namespaces will differ. This can for instance be very useful when you connect a <label> with an <input>. Example in Velocity:
#set ($portletContextUtil = $sitevisionUtils.portletContextUtil)
...
#set ($ns = $portletContextUtil.getPortletNamespace('name'))
<label for="$ns">Name: </label><input id="$ns" name="name" type="text" />
The namespace generated in the above example (i.e. $ns
) could be something like: name12_2b9561c511855e0ab91800015
aPrefix
- the prefix for the namespace (ensure it only contains chars that are valid in an id value if you use it as such)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-2018 SiteVision AB, all rights reserved.