« Back to Development

Portlet namespace

Tags: development

Table of Contents [-]

Introduction #

Namespacing ensures that the given name is uniquely associated with this portlet and avoids name conflicts with other elements on the portal page or with other portlets on the page.

To use it you must import standard portlet library

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

This tag produces a unique value for the current portlet:


Here is an example how to use it in the code:

    function <portlet:namespace />myFunction() {
       alert("<portlet:namespace />myButton was clicked" );
  <input type="button" id="<portlet:namespace />myButton" onclick="<portlet:namespace />myFunction();">
0 Attachments
Average (2 Votes)
The average rating is 3.5 stars out of 5.
Threaded Replies Author Date
Thanks for the info. However I have discovered... Armaz Mellati April 2, 2013 12:40 PM
Hi There, I know this is a late reply, but I... Jared Nagle October 29, 2014 9:21 PM

Thanks for the info. However I have discovered that <portlet:namespace /> does not work inside aui-taglib elements. That's a real pain. Would love to hear from someone how to do in in a case like this:
<aui:button cssClass="<portlet:namespace />myButton" name="create" type="button"></aui:button>
Posted on 4/2/13 12:40 PM.
Hi There,

I know this is a late reply, but I have found this works:

<c:set var="ns" value="${renderResponse.getNamespace()}" />
<aui:button ... cssClass="${ns}myButton" ... />
Posted on 10/29/14 9:21 PM in reply to Armaz Mellati.