Generic method to get ObjectID from unique Name

When your using Portal SPI or POrtal Controller SPI to either read portal information or modify it, you will notice that most of the methods take as argument. So far i used object specific methods to get the ObjectID from unique name

But it seems that you can use the following method to look up ObjectID from JNDI COntext

private ObjectID getObjectID(String uniqueNameStr){
try {
InitialContext ctx = new InitialContext();
final Name uniqueName = new CompositeName("portal:uniquename");
ObjectID oidForUniqueName = (ObjectID) ctx.lookup(uniqueName);
return oidForUniqueName;
} catch (InvalidNameException e) {
} catch (NamingException e) {
return null;

You can call this method with unique name of either page, portlet or navigation node and it will return you the instance of for that unique name.

I tried calling it for a page, portlet and Portlet Window like this

protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering DynamicUIPortlet.doView()");
PrintWriter out = response.getWriter();
out.println("com.webspherenotes.popup.static " +
getObjectID("com.webspherenotes.popup.static") +"
out.println("com.webspherenotes.popup.control " +
getObjectID("com.webspherenotes.popup.control") +"
out.println("com.webspherenotes.popup.portlet " +
getObjectID("com.webspherenotes.popup.portlet") +"
System.out.println("Exiting DynamicUIPortlet.doView()");

I am calling the getObjectID() method with different unique names and printing output in the doView() method this is what i get


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... 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