Using portlet application name and portlet name to lookup a portlet

In the Generic method to get ObjectID from unique Name entry i talked about how you can find out ObjectID of a portlet/page or any other object from its unique name. BUt what if you want to find a portlet that does not have a uniuename assigned to it. In that case you can use combination of Portlet Application's uid and Portlet Name to find the portlet, you can use this method for that


private ObjectID getPortletObjectId(String portletAppId, String portletNameStr){
try {
InitialContext ctx = new InitialContext();
Name portletName = new CompositeName("portal:config/portletdefinition");
portletName.add(portletAppId ); //portal app Id
portletName.add(portletNameStr); //Portlet name
ObjectID portletDefOID = (ObjectID) ctx.lookup(portletName);
//ObjectID oidForUniqueName = (ObjectID) ctx.lookup(portletName);
return portletDefOID;
} catch (InvalidNameException e) {
e.printStackTrace(System.out);
} catch (NamingException e) {
e.printStackTrace(System.out);
}
return null;
}


This method takes portlet application id and the portletName to find out the portlet as argument and returns ObjectID. Now the question is what should be the value of the portlet object id and portlet name, you can find those values from the xmlaccess export of the portlet application


<web-app action="update" active="true" domain="rel"
objectid="1_VVILMKG100OPD0II63CET20000" removable="true" uid="PopupPortlet.war.webmod">
<url>file://localhost/$user_install_root$/PortalServer/deployed/archive/PopupPortlet.war.webmod/PopupPortlet.war</url>
<context-root>/wpcert/PA_Popup</context-root>
<display-name>PA_Popup</display-name>
<access-control externalized="false"
owner="uid=wasadmin,o=defaultwimfilebasedrealm" private="false"/>
<servlet action="update" active="true" domain="rel" name="PopupPortlet"
objectid="V_VVILMKG100OPD0II63CET20002" remote-cache-dynamic="false"/>
<portlet-app action="update" active="true" defaultlocale="en" domain="rel"
name="Application Name not available for this Application" objectid="2_VVILMKG100OPD0II63CET20004" uid="PopupPortlet.war" >
<access-control externalized="false" owner="uid=wasadmin,o=defaultwimfilebasedrealm" private="false"/>
<portlet action="update" active="true" defaultlocale="en" domain="rel"
name="PopupPortlet" objectid="3_VVILMKG100OPD0II63CET20006"
provided="false" servletref="V_VVILMKG100OPD0II63CET20002"
uniquename="com.webspherenotes.popup.portlet">
<access-control externalized="false"
owner="uid=wasadmin,o=defaultwimfilebasedrealm" private="false">
<role actionset="User" update="set">
<mapping subjectid="anonymous portal user"
subjecttype="user" update="set"/>
</role>
</access-control>
</portlet>
</portlet-app>
</web-app>



  • portletAppId: Value of uid attribute of portlet-app element

  • portletName: Value of name attribute of portlet element



I can use getPortletObjectId("PopupPortlet.war", "PopupPortlet"); to find out the ObjectID of the PopupPortlet

3 comments:

srjwebsolutions said...


We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said...

Egmedi.com is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery


Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store