Some important utility methods provided by PortletUtils class

0 comments



PortletUtils (under package com.ibm.wps.pb.utils.portlet) is a utility class which is provided by WebSphere portal server. With help of JSR286 API, it provides some very useful methods.



getPortletDefinitionId(PortletConfig portletconfig)
String portletUniqueName = "";
ObjectID objID = PortletUtils.getPortletDefinitionId(getPortletConfig());
if(null != objID) {
     portletUniqueName = objID.getUniqueName();
}


getPortletDefinitionId(javax.portlet.PortletRequest portletrequest)
String portletUniqueName = "";
ObjectID objID = PortletUtils.getPortletDefinitionId(request)
if(null != objID) {
    portletUniqueName = objID.getUniqueName();
}


getHttpServletRequest(javax.portlet.PortletRequest portletrequest)
Assuming that the current URL is something like
http://localhost:10039/wps/myportal/IVTc2U0QyMEEz/?paramName=paramValue
HttpServletRequest request=PortletUtils.getHttpServletRequest(request);
System.out.println("ParameterValue"+request.getParameter("paramName"));
// paramValue is printed.


getHttpServletResponse(javax.portlet.PortletResponse portletresponse)
HttpServletResponse req=PortletUtils.getHttpServletRequest(response);


getUser(javax.portlet.PortletRequest portletrequest)
User user= PortletUtils. getUser (request);


getPageId(HttpServletRequest httpservletrequest)
String pageuniquename = "";
ObjectID objID = PortletUtils.getPageId(req);
if(null != objID) {
    pageuniquename = objID.getUniqueName();
}

No comments:

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club