« 返回到 Development

Portlet namespace

标签: 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:

<portlet:namespace/>
.

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

  <script>
    function <portlet:namespace />myFunction() {
       alert("<portlet:namespace />myButton was clicked" );
    }
  </script>
  <input type="button" id="<portlet:namespace />myButton" onclick="<portlet:namespace />myFunction();">
0 附件
67185 查看
平均 (2 票)
满分为 5,平均得分为 3.5。
评论
讨论主题回复 作者 日期
Thanks for the info. However I have discovered... Armaz Mellati 2013年4月2日 下午12:40
Hi There, I know this is a late reply, but I... Jared Nagle 2014年10月29日 下午9:21

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>
在 13-4-2 下午12:40 发帖。
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" ... />
在 14-10-29 下午9:21 发帖以回复 Armaz Mellati