Copyright© 2008-2024 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 |
---|---|
Node |
getCurrentDashboard()
Gets current dashboard node (applicable during render of a sv:widgetCustomModule).
|
Node |
getCurrentDecoratedNode()
Gets current decorated node (applicable during render of a sv:decorationTemplate).
|
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 |
getNonce()
Gets a unique nonce for this request.
|
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)Node getCurrentDashboard()
Node
, or null
if indeterminable
(i.e. this method is not called from within a sv:widgetCustomModule)Locale getCurrentLocale()
Locale
, or default Locale
if indeterminableNodeResolverUtil.getLocaleResolver()
Node getCurrentUser()
Node
, or null
if indeterminableNode getCurrentUserIdentity()
Node
, or null
if indeterminableNode getCurrentDecoratedNode()
This method returns the "decorated" node (typically a sv:portlet or sv:layout) during render of a sv:decorationTemplate. In other words - it returns the node that is decorated with the template-based decoration that is now rendering.
@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)String getNonce()
The nonce should be used for all client-side inline javascript (e.g. <script nonce="..."> ... <script>
).
If not specified, the script might be blocked and ignored by the client/browser due to the content security policy settings of the page
(i.e. typically when the CSP has no "unsafe-inline" specified).
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-2024 Sitevision AB, all rights reserved.