• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is session always required to accomplish this?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I suppose it�s a very genuine problem with portlet, I am facing.

When I submit the form, I get all the parameters in processAction() method (in ActionRequest), I do some processing, now I want to set some attributes in request to render them on GUI but rendering part is handled by doView() method, where I have access of RenderRequest, not of ActionRequest. How to achieve this kind of very common functionality?

I don't want to set those attributes in session.

Please help.
Thanks.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ankur,

Using the setRenderParameter and setRenderParameters methods of the ActionResponse interface, you can set render parameters during an action request. After setting in action phase these parameters will be available in render phase (e.g. doView()) and can be retrieved from RenderRequest.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed, using the PortletSession to achieve this functionality is a waste. You don't want to overburden your session.

Setting the swapping properties into the renderparameter in the action phase, and pulling them out in the render phase is definitely the way to go.

Here's a little help from the Sun API JavaDoc for the Portlet JSR168 Spec:


setRenderParameters

public void setRenderParameters(java.util.Map parameters)

Sets a parameter map for the render request.

All previously set render parameters are cleared.

These parameters will be accessible in all sub-sequent render calls via the PortletRequest.getParameter call until a new request is targeted to the portlet.

The given parameters do not need to be encoded prior to calling this method.

Parameters:
parameters - Map containing parameter names for the render phase as keys and parameter values as map values. The keys in the parameter map must be of type String. The values in the parameter map must be of type String array (String[]).
Throws:
java.lang.IllegalArgumentException - if parameters is null.

setRenderParameter

public void setRenderParameter(java.lang.String key,
java.lang.String value)

Sets a String parameter for the render request.

These parameters will be accessible in all sub-sequent render calls via the PortletRequest.getParameter call until a request is targeted to the portlet.

This method resets all parameters with the same key.

The given parameter do not need to be encoded prior to calling this method.

Parameters:
key - key of the render parameter
value - value of the render parameter
Throws:
java.lang.IllegalArgumentException - if key or value is null.





-Cameron McKenzie
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Hemant and Cameron,

Actually I figured it out after posting the question but let it went because my question anyway talks about attributes. How to pass attribute (objects other than string) to doView() or render process?

Thanks again.
 
reply
    Bookmark Topic Watch Topic
  • New Topic