Forums de discussion

How to get portlet instance id in jspx?

Chew Boon Aik, modifié il y a 13 années.

How to get portlet instance id in jspx?

New Member Publications: 13 Date d'inscription: 05/03/10 Publications récentes
I have a jspx

<!--?xml version="1.0" encoding="UTF-8"?-->
<jsp:root version="2.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:portlet="http://java.sun.com/portlet">
...
...
</jsp:root>


How to get portlet instance id so that I could make my javascript functions are per portlet instance, like

<script>
	function ${portletInstanceId}_animate() {
		jQuery(".${portletInstanceId}-animate").animate(...
	}
</script>


I tried

<liferay-theme:defineobjects />
<c:set var="portletInstanceId" value="${themeDisplay.portletDisplay.instanceId}" />


But didn't work. Any idea?
Chew Boon Aik, modifié il y a 13 années.

RE: How to get portlet instance id in jspx?

New Member Publications: 13 Date d'inscription: 05/03/10 Publications récentes
Oh silly me. It can easily be done by

<c:set var="ns"><portlet:namespace /></c:set>


Then I could use it anywhere

<script>
	function ${ns}submit() {
		...
		...
	}
</script>