JSR 168 Version.
<%
PortletServiceHome psHomeModel = null;
PortletModelProvider modelProvider = null;
PortletWindow pWindow = null;
if (psHomeModel == null ){
Context ctx = new InitialContext();
psHomeModel = (PortletServiceHome)
ctx.lookup(
"portletservice/com.ibm.portal.portlet.service.model.PortletModelProvider"
);
}
try {
modelProvider =
(PortletModelProvider) psHomeModel.getPortletService(PortletModelProvider.class
);
pWindow =
modelProvider.getCurrentPortletWindow(renderRequest);
PortletModel pModel =
modelProvider.getPortletModel(renderRequest, renderResponse);
PortletDefinition
pDefinition = pModel.getPortletDefinition(pWindow);
PortletEntity pEntity =
pModel.getPortletEntity(pWindow);
com.ibm.portal.portletmodel.Portlet portlet = pModel.getPortlet(pDefinition);
WebApplication webApp =
pModel.getWebApplication(portlet);%>
This is the uniqueName
for the Window = <%=pWindow.getObjectID().getUniqueName() %>
This is the uniqueName
for the Portlet Definition = <%=pDefinition.getObjectID().getUniqueName() %>
This is the
uniqueName for the portlet Entity = <%=pEntity.getObjectID().getUniqueName()
%>
This is the
unqiueName for the Portlet = <%=portlet.getObjectID().getUniqueName() %>
This is the uniqueName
for the WebApp = <%=webApp.getObjectID().getUniqueName() %>
<%
} catch (Exception ex) {
%>the portlet window was unable to be
retrieved<%
} %>
From these basic you can get portlet definitions as well as other
representations of the portlet model. This is a read only model though and not
a an updateable model
Legacy API
<%
PortletWindow pWindow = null;
PortletModelProvider modelProvider = (PortletModelProvider)
portletConfig.getContext().getService(com.ibm.portal.ibmportlet.service.model.Po
rtletModelProvider.class);
try {
//modelProvider =
(PortletModelProvider)
psHomeModel.getPortletService(PortletModelProvider.class);
pWindow =
modelProvider.getCurrentPortletWindow(portletRequest);
PortletModel pModel =
modelProvider.getPortletModel(portletRequest, portletResponse);
PortletDefinition
pDefinition = pModel.getPortletDefinition(pWindow);
PortletEntity pEntity =
pModel.getPortletEntity(pWindow);
com.ibm.portal.portletmodel.Portlet portlet = pModel.getPortlet(pDefinition);
WebApplication webApp =
pModel.getWebApplication(portlet);%>
This is the uniqueName
for the Window = <%=pWindow.getObjectID().getUniqueName() %>
This is the uniqueName
for the Portlet Definition = <%=pDefinition.getObjectID().getUniqueName() %>
this is the
uniqueName for the portlet Entity = <%=pEntity.getObjectID().getUniqueName()
%>
This is the
unqiueName for the Portlet = <%=portlet.getObjectID().getUniqueName() %>
This is the uniqueName
for the WebApp = <%=webApp.getObjectID().getUniqueName() %>
<%
} catch (Exception ex) {
%>the portlet window was unable to be
retrieved<%
} %>
This post provides sample code for Portlet
Model SPI.