In this line : portletRequest=(PortletRequest)getFacesContext().getExternalContext().getRequest();
But the Object we are getting here can not be Type casted to Portlet request. So its throwing exception.
Is there any way to get PortletSession in in PageCodeBase?
-Thanks in advance
IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0
The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
PortletRequest request = (PortletRequest)FacesContext.
getCurrentInstance().getExternalContext().getRequest();
But when I type cast it to HttpServletRequest, the portlet is getting displayed.
i.e HttpServletRequest request = (HttpServletRequest )FacesContext.
getCurrentInstance().getExternalContext().getRequest();
So I guess, the request object we are getting from external context cant be type casted to PortletRequest.
I am stuck up here to get portletSession, since I need to communicate the change done in one page(portlet) has to be communicated to another page (another portlet).
Any solution for this is highly appreciated.
Thanks
I have created faces portlets by these 2 options
When I created the faces portlet using first option, I was getting class cast exception
PortletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
But when I created faces portlet using second option I was able to type cast the request into Portlet Request.
So what is the difference between these two kind of project
Portlet Project and Portlet Project(JSR 168)
I tried HttpSession also, the attributes in the HttpSession is also not shared among portlets.
Your suggestion is helpful..
First, you can get portlet request using the API you qouted in both cases, however if you are using a legacy portlet, not JSR168, PortletRequest would be a different class in a different package, so I presume you are casting it to the wrong class.
Second, you don't even need the request object to get to the session in JSF. You can get the session straight from the External Context:
FacesContext.getCurrentInstance().getExternalContent().getSessionMap()
However this session is not shared between the portlets, as we can acheive in JSR 168 by mentioning (APPLICATION_SCOPE).
the second point you mentioned getting sessionscoped Map by "FacesContext.getCurrentInstance().getExternalContent().getSessionMap()" also doesnt shared between portlet.
Jim has provided the link that we could achieve this by creating PortletService.
Can we acheive the sharing of information between the portlets by using existing API?