Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • WebSphere Portal Family wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category IBM Redbooks: Building a Sample Website Using IBM Web Content Manager 7.0 IBM Redbooks: Building and Implementing a Social Portal IBM Redbooks: Developing Exceptional Multi-Channel Web Experiences V7: IBM Web Content Manager Product Documentation V7: IBM WebSphere Portal Enable for z/OS Product Documentation V7: IBM WebSphere Portal Express Product Documentation V7: WebSphere Portal Product Documentation V8: IBM Web Content Manager Product Documentation V8: IBM WebSphere Portal Express Product Documentation V8: IBM WebSphere Portal Product Documentation (includes z/OS) Custom Search Scope...
Search
Community Articles > WebSphere Portal > Sample Code for Portlet Model SPI
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

James Barnes
Contribution Summary:
  • Articles authored: 4
  • Articles edited: 2
  • Comments Posted: 3

Recent articles by this author

How to deploy a theme as a custom war into WebSphere Application server console

This will outline the steps needed to deploy a theme through the WebSphere AppServer console.

Developing with the PUMA SPI

First you need to get the PUMA Profile javax.naming.Context ctx = new javax.naming.InitialContext(); PortletServiceHome psh = (PortletServiceHome) ctx.lookup("portletservice/com.ibm.portal

Development with the Navigation Model SPI

Get the Current Selected Page public static ObjectID getCurrentPage(PortletRequest request, PortletResponse response) throws StateException, NamingException, IOExcepti

Sample Code for Portlet Model SPI

This post provides sample code for Portlet Model SPI.

Community articleSample Code for Portlet Model SPI

Added by James Barnes | Edited by IBM contributor DeAnna Steiner on July 7, 2008 | Version 11
  • Edit
  • More Actions Show Menu▼
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: development, 6.0, portlets, jsr 168, legacy api

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.  

  • Edit
  • More Actions Show Menu▼


expanded Attachments (0)
collapsed Attachments (0)
Edit the article to add or modify attachments.
expanded Versions (11)
collapsed Versions (11)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (11)Jul 7, 2008 5:20:19 PMDeAnna Steiner  IBM contributor
10Jul 7, 2008 5:18:42 PMDeAnna Steiner  IBM contributor
9Jul 7, 2008 5:01:57 PMDeAnna Steiner  IBM contributor
7Jul 1, 2008 6:36:25 PMDeAnna Steiner  IBM contributor
6Jul 1, 2008 6:36:25 PMDeAnna Steiner  IBM contributor
5Jun 29, 2008 10:45:24 PMMary Carbonara  IBM contributor
4Jun 13, 2008 4:03:10 PMDeAnna Steiner  IBM contributor
3Jun 13, 2008 3:58:29 PMDeAnna Steiner  IBM contributor
2May 23, 2008 11:47:24 AMJames Barnes  IBM contributor
1May 23, 2008 10:21:39 AMJames Barnes  IBM contributor
1May 23, 2008 10:21:39 AMJames Barnes  IBM contributor
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use