掲示板

Portlet Session

10年前 に Kevin Matthews によって更新されました。

Portlet Session

Junior Member 投稿: 38 参加年月日: 12/05/23 最新の投稿
Hello, I have a portlet class that extends the GenericPortlet. I am having difficult in accessing data out of session in one of my portlet JSP. I can access data out of session from one portlet class to another rportlet class (i.e class <->class)using PortletSession object but I can not get data from another portlet jsp (i.e class->JSP).
Here are details below:
:
PORTLET A (class)
INSIDE PORTLET CLASS:
@ProcessAction(name = "processClaim")
public void processClaim(ActionRequest actionRequest,ActionResponse actionResponse){
actionRequest.getPortletSession().setAttribute("closedText", resp.getClosedText(), PortletSession.APPLICATION_SCOPE); <- Settion data in Session in Portlet A
actionResponse.sendRedirect(viewMyRegisteredClaimPage+"?id="+ref);
}

PORTLET B (jsp)
INSIDE REDIRECTED PORTLET JSP:
HttpServletRequest r = PortalUtil.getHttpServletRequest(renderRequest);
String claimReference = PortalUtil.getOriginalServletRequest(r).getParameter("id");

String closedCLaim = (String)portletSession.getAttribute("closedText"); <- Retrieving the data out of session in Portlet B
System.out.println("CLOSED TEXT = ["+closedCLaim+"]");

I am getting null when trying to get closedText.

How can I get or read the values from Session?

Thanks,
Kevin
thumbnail
10年前 に Ritesh Gajera によって更新されました。

RE: Portlet Session

Junior Member 投稿: 66 参加年月日: 12/02/21 最新の投稿
Kevin,

You can retrieve or read the values from Session like this.

Read session:

PortletSession session= renderRequest.getPortletSession();
String str= (String)session.getAttribute("sessionValue",PortletSession.APPLICATION_SCOPE);

Kindly Refer this link also,
https://www.liferay.com/community/forums/-/message_boards/message/13435987
http://www.liferayaddict.com/home/-/blogs/45920;jsessionid=7224077DADC6AB8D8C61849FC2B053FE

Regards,
Ritesh
10年前 に Kevin Matthews によって更新されました。

RE: Portlet Session

Junior Member 投稿: 38 参加年月日: 12/05/23 最新の投稿
Thanks Ritest. that works:

Actually it is :

String closedCLaim = (String)portletSession.getAttribute("closedText", portletSession.APPLICATION_SCOPE);

(i.e if you include the <portlet:defineObjects />)

-Kevin