|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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></name> <value>true</value> <value>CachedScopes</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, IException { // // retrieve the attribute from the portlet session // 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 = "/"; private Log log = LogFactory.getLog(this.getClass()); public void doView(RenderRequest request, RenderResponse response) throws PortletException, IException { 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, IException { // // set attribute to portlet session // request.getPortletSession().setAttribute("MYVAR", "This is my variable"); } } |
|
#2
|
|||
|
|||
|
Pluto-2.0 portletSession cannot share parameters !!!
Eric, The attributes need to be set on the PortletRequest, not the PortletSession. /Craig -----"Eric Chow" <eric138 (AT) gmail (DOT) com> wrote: ----- To: pluto-dev (AT) portals (DOT) apache.org From: "Eric Chow" <eric138 (AT) gmail (DOT) com> 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_PAG E); requestDispatcher.include(request, response); } public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { // ------------------------------------------------------------------------------------------------------------------------- // ------------------------------------------- set attribute to portlet session // ------------------------------------------------------------------------------------------------------------------------- request.getPortletSession().setAttribu te("MYVAR", "This is my variable"); } } |
|
#3
|
|||
|
|||
|
Pluto-2.0 portletSession cannot share parameters !!!
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- CDoremus (AT) hannaford (DOT) com wrote: Eric, The attributes need to be set on the PortletRequest, not the PortletSession. /Craig -----"Eric Chow" <eric138 (AT) gmail (DOT) com> wrote: ----- To: pluto-dev (AT) portals (DOT) apache.org From: "Eric Chow" <eric138 (AT) gmail (DOT) com> 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_PAG E); requestDispatcher.include(request, response); } public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { // ------------------------------------------------------------------------------------------------------------------------- // ------------------------------------------- set attribute to portlet session // ------------------------------------------------------------------------------------------------------------------------- request.getPortletSession().setAttribu te("MYVAR", "This is my variable"); } } |
![]() |
| Viewing: Web Development Archives > Mailing Lists > Apache > Pluto-2.0 portletSession cannot share parameters !!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|