Sometimes you might need to dynamically determine the IDs of all portlets placed in certain pages. Here is how you can do it:
List<String> portletIdList = themeDisplay.getLayoutTypePortlet().getPortletIds(); for(String pid : portletIdList) { out.println(pid+"<br>"); }
That’s it!