Hi,
Sorry, but I did not read the post carefully enough. Yes, in order for two
portlets to communicate (pass data), you need to use either public render
parameters or portlet events. The
javax.portlet.actionScopedRequestAttributes container runtime option can be
used by a single portlet to pass request attribute data from the
processAction() method to the processEvent() or render() methods. It cannot
be used for interportlet communication.
/Craig
Michael Freedman
<michael.freedman
@oracle.com> To
[email protected]
07/08/2008 11:17 cc
AM
Subject
Re: Pluto-2.0 portletSession cannot
Please respond to share parameters !!!
[EMAIL PROTECTED]
.apache.org
technically, you should only use public render parameters or events to
share state between portlets. Though using the PortletRequest might work
in Pluto it is not standard and you wil lfind that this won't work on many
portlet containers. You can rely on the PortletSession however you must
put the data in APPLICATION_SCOPE not PORTLET_SCOPE (the default) if you
want all portlets in the same web application to see the attribute.
-Mike-
[EMAIL PROTECTED] wrote:
Eric,
The attributes need to be set on the PortletRequest, not the
PortletSession.
/Craig
-----"Eric Chow" <[EMAIL PROTECTED]> wrote: -----
To: [email protected]
From: "Eric Chow" <[EMAIL PROTECTED]>
Date: 07/04/2008 05:26AM
Subject: Pluto-2.0 portletSession cannot share parameters !!!
Hello,
I am testing the Pluto-2.0. I could not retrieve the attributes from
PortletSession.
For example,
I use portletSession.setAttribute("MYVAR", "some value") in
PortletA,
and retrieve it in PortletB, but it always returned "null".
I tried to add the following in the portlet.xml in application
level.
<container-runtime-option>
<name>javax.portlet.actionScopedRequestAttributes</name>
<value>true</value>
<value>numberOfCachedScopes</value>
<value>10</value>
</container-runtime-option>
Is there any bug ?
Best regards,
Eric
-----------
public class HelloWorldPortlet extends GenericPortlet {
public static final String VIEW_PAGE =
"/WEB-INF/portlets/demo/view.jsp";
public void doView(RenderRequest request, RenderResponse
response)
throws PortletException, IOException {
//
-------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------- retrieve the
attribute from the portlet session
// -------------------------------------------always
return NULL
------------------------------------------------------------------------------
System.out.println("......................" +
request.getPortletSession().getAttribute("MYVAR"));
response.setContentType("text/html");
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(VIEW_PAGE);
requestDispatcher.include(request, response);
}
}
------------------
public class LocalePortlet extends GenericPortlet {
private static final String VIEW_PAGE =
"/WEB-INF/portlets/framework/locale/view.jsp";
private Log log = LogFactory.getLog(this.getClass());
public void doView(RenderRequest request, RenderResponse
response)
throws PortletException, IOException {
response.setContentType("text/html");
PortletContext context = getPortletContext();
PortletRequestDispatcher requestDispatcher = context
.getRequestDispatcher(VIEW_PAGE);
requestDispatcher.include(request, response);
}
public void processAction(ActionRequest request, ActionResponse
response)
throws PortletException, IOException {
//
-------------------------------------------------------------------------------------------------------------------------
// ------------------------------------------- set attribute
to
portlet session
//
-------------------------------------------------------------------------------------------------------------------------
request.getPortletSession().setAttribute("MYVAR", "This is
my variable");
}
}