Apache
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives Mailing Lists Apache

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 4th, 2008, 07:01 AM
Eric Chow
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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");
}

}

Reply With Quote
  #2  
Old July 7th, 2008, 08:20 PM
CDoremus
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Pluto-2.0 portletSession cannot share parameters !!!



Eric,



&nbsp;



The attributes need to be set on the PortletRequest, not the PortletSession.
/Craig





&nbsp;



&nbsp;



&nbsp;




&nbsp;

-----"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.



&nbsp;<container-runtime-option>
&nbsp; &nbsp; &nbsp;<name>javax.portlet.actionScopedRequestAttributes</name>
&nbsp; &nbsp; &nbsp;<value>true</value>
&nbsp; &nbsp; &nbsp;<value>numberOfCachedScopes</value>
&nbsp; &nbsp; &nbsp;<value>10</value>
&nbsp;</container-runtime-option>




Is there any bug ?

Best regards,
Eric



-----------
public class HelloWorldPortlet extends GenericPortlet {
&nbsp;&nbsp;&nbsp;&nbsp;public static final String VIEW_PAGE = "/WEB-INF/portlets/demo/view.jsp";


&nbsp;&nbsp;&nbsp;&nbsp;public void doView(RenderRequest request, RenderResponse response)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throws PortletException, IOException {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// -------------------------------------------------------------------------------------------------------------------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ------------------------------------------- retrieve the
attribute from the portlet session
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // -------------------------------------------always
return NULL ------------------------------------------------------------------------------

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("......................." +
request.getPortletSession().getAttribute("MYVAR"));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setContentType("text/html");
&nbsp; &nbsp; &nbsp; &nbsp;PortletContext context = getPortletContext();
&nbsp; &nbsp; &nbsp; &nbsp;PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(VIEW_PAGE);
&nbsp; &nbsp; &nbsp; &nbsp;requestDispatcher.include(request, response);

&nbsp;&nbsp;&nbsp;&nbsp;}
}






------------------

public class LocalePortlet extends GenericPortlet {
&nbsp;&nbsp;&nbsp;&nbsp;private static final String VIEW_PAGE =
"/WEB-INF/portlets/framework/locale/view.jsp";

&nbsp;&nbsp;&nbsp;&nbsp;private Log log = LogFactory.getLog(this.getClass());
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;public void doView(RenderRequest request, RenderResponse response)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throws PortletException, IOException {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setContentType("text/html");

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PortletContext context = getPortletContext();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PortletRequestDispatcher requestDispatcher = context
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getRequestDispatcher(VIEW_PAG E);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;requestDispatcher.include(request, response);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;public void processAction(ActionRequest request, ActionResponse response)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throws PortletException, IOException {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //
-------------------------------------------------------------------------------------------------------------------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ------------------------------------------- set attribute to
portlet session
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //
-------------------------------------------------------------------------------------------------------------------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.getPortletSession().setAttribu te("MYVAR", "This is my variable");
&nbsp;&nbsp;&nbsp;&nbsp;}

}




Reply With Quote
  #3  
Old July 8th, 2008, 12:02 PM
Michael Freedman
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Pluto-2.0 portletSession cannot share parameters !!!

technically, you should only use public render parameters or events to share state between portlets.&nbsp; 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.&nbsp; 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.
&nbsp;&nbsp;&nbsp; -Mike-

CDoremus (AT) hannaford (DOT) com wrote:

Eric,



&nbsp;



The attributes need to be set on the PortletRequest, not the PortletSession.
/Craig





&nbsp;



&nbsp;



&nbsp;




&nbsp;

-----"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.



&nbsp;<container-runtime-option>
&nbsp; &nbsp; &nbsp;<name>javax.portlet.actionScopedRequestAttributes</name>
&nbsp; &nbsp; &nbsp;<value>true</value>
&nbsp; &nbsp; &nbsp;<value>numberOfCachedScopes</value>
&nbsp; &nbsp; &nbsp;<value>10</value>
&nbsp;</container-runtime-option>




Is there any bug ?

Best regards,
Eric



-----------
public class HelloWorldPortlet extends GenericPortlet {
&nbsp;&nbsp;&nbsp;&nbsp;public static final String VIEW_PAGE = "/WEB-INF/portlets/demo/view.jsp";


&nbsp;&nbsp;&nbsp;&nbsp;public void doView(RenderRequest request, RenderResponse response)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throws PortletException, IOException {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
// -------------------------------------------------------------------------------------------------------------------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ------------------------------------------- retrieve the
attribute from the portlet session
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // -------------------------------------------always
return NULL ------------------------------------------------------------------------------

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println("......................" +
request.getPortletSession().getAttribute("MYVAR"));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setContentType("text/html");
&nbsp; &nbsp; &nbsp; &nbsp;PortletContext context = getPortletContext();
&nbsp; &nbsp; &nbsp; &nbsp;PortletRequestDispatcher requestDispatcher =
context.getRequestDispatcher(VIEW_PAGE);
&nbsp; &nbsp; &nbsp; &nbsp;requestDispatcher.include(request, response);

&nbsp;&nbsp;&nbsp;&nbsp;}
}






------------------

public class LocalePortlet extends GenericPortlet {
&nbsp;&nbsp;&nbsp;&nbsp;private static final String VIEW_PAGE =
"/WEB-INF/portlets/framework/locale/view.jsp";

&nbsp;&nbsp;&nbsp;&nbsp;private Log log = LogFactory.getLog(this.getClass());
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;public void doView(RenderRequest request, RenderResponse response)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throws PortletException, IOException {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setContentType("text/html");

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PortletContext context = getPortletContext();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PortletRequestDispatcher requestDispatcher = context
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getRequestDispatcher(VIEW_PAG E);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;requestDispatcher.include(request, response);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;public void processAction(ActionRequest request, ActionResponse response)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throws PortletException, IOException {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //
-------------------------------------------------------------------------------------------------------------------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ------------------------------------------- set attribute to
portlet session
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //
-------------------------------------------------------------------------------------------------------------------------
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.getPortletSession().setAttribu te("MYVAR", "This is my variable");
&nbsp;&nbsp;&nbsp;&nbsp;}

}




Reply With Quote
Reply

Viewing: Web Development Archives Mailing Lists Apache > Pluto-2.0 portletSession cannot share parameters !!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT