To get the portlet mode in JSF's managed bean, you need to do
Object reqObj = FacesContext.getCurrentInstance().getExternalContext().getRequest();
if (reqObj instanceof PortletRequest){
request = (PortletRequest)reqObj;
return request.getPortletMode();
}
You can get PortletPreferences similary by using request.getPreferences().
To get init parameters that you have specified in portlet.xml, you use
Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
if (null != applicationMap)
{
PortletConfig config = (PortletConfig)applicationMap.get("javax.portlet.PortletConfig");
return config.getInitParameter(param);
}
1 comment:
Hi,
is there another way for getting portlet init parameters?
My problem is: I have two jsf portlets in the same web application (two portlets defined in portlet.xml), if I invoke first the portlet 1 and subsequently the portlet 2, I retrieve the init-params related to the first portlet invoked.
Thank you in advance.
Angelo
Post a Comment