How to get Portlet Window ID

You can get WindowId of the portlet inside your portlet using request.getWindowID() method. This method was introduced in the JSR 286.


System.out.println("Portlet Window Id -> " +request.getWindowID());
System.out.println("Portlet Name Space -> " +response.getNamespace());


I tried printing the following two values in the System.out and this is what i get


Portlet Window Id -> 7_VVILMKG100N080IA0G757C00O3
Portlet Name Space -> ns_7_VVILMKG100N080IA0G757C00O3_


As you can see the name space is nothing but ns_portletwindowid_

If export page definition this is what you will get, as you can see the portletWindowId is nothing but objectId of the control element that holds this portlet


<?xml version="1.0" encoding="UTF-8"?>

<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" build="wp6103_201_01" type="update" version="6.1.0.3"
xsi:noNamespaceSchemaLocation="PortalConfig_6.1.0.2.xsd">
<portal action="locate">
<web-app action="locate" domain="rel" objectid="1_VVILMKG100N080IA0G757C0000" uid="ServletPopup.war.webmod">
<servlet action="locate" domain="rel" name="ServletPopup" objectid="V_VVILMKG100N080IA0G757C0002"/>
<portlet-app action="locate" domain="rel" name="Application Name not available for this Application" objectid="2_VVILMKG100N080IA0G757C0004"
uid="ServletPopup.war">
<portlet action="locate" domain="rel" name="ServletPopup" objectid="3_VVILMKG100N080IA0G757C0006"/>
</portlet-app>
</web-app>
<content-node action="locate" domain="rel" objectid="6_000000000000000000000000A0" uniquename="wps.content.root"/>
<content-node action="locate" domain="rel" objectid="6_CGAH47L008IC40I4BOR2EO00I3" uniquename="ibm.portal.Home"/>
<content-node action="locate" domain="rel" objectid="6_VVILMKG10GUS50I24V0O5Q2002"/>
<content-node action="locate" domain="rel" objectid="6_VVILMKG100OPD0II63CET20007"/>
<content-node action="update" active="true" allportletsallowed="true" content-parentref="6_VVILMKG100OPD0II63CET20007" create-type="explicit"
domain="rel" objectid="6_VVILMKG108SFA0IIDM2Q113007" ordinal="100" type="page">
<supported-markup markup="html" update="set"/>
<localedata locale="en">
<title>Popup Client Portlet</title>
</localedata>
<parameter name="com.ibm.portal.IgnoreAccessControlInCaches" type="string" update="set"><![CDATA[false]]></parameter>
<parameter name="com.ibm.portal.bookmarkable" type="string" update="set"><![CDATA[Yes]]></parameter>
<parameter name="com.ibm.portal.remote-cache-expiry" type="string" update="set"><![CDATA[0]]></parameter>
<parameter name="com.ibm.portal.remote-cache-scope" type="string" update="set"><![CDATA[NON-SHARED]]></parameter>
<access-control externalized="false" owner="uid=wasadmin,o=defaultWIMFileBasedRealm" private="false"/>
<component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_VVILMKG108SFA0IIDM2Q1130G0"
ordinal="100" orientation="H" skinref="undefined" type="container" width="undefined">
<component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_VVILMKG108SFA0IIDM2Q1130G4"
ordinal="100" orientation="V" skinref="undefined" type="container" width="undefined">
<component action="update" active="true" deletable="undefined" domain="rel" modifiable="undefined" objectid="7_VVILMKG100N080IA0G757C00O3"
ordinal="100" skinref="undefined" type="control" width="undefined">
<portletinstance action="update" domain="rel" objectid="5_VVILMKG100N080IA0G757C00O7" portletref="3_VVILMKG100N080IA0G757C0006"/>
</component>
</component>
</component>
</content-node>
</portal>
<status element="all" result="ok"/>
</request>