File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Portals and Portlets and the fly likes is session always required to accomplish this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "is session always required to accomplish this?" Watch "is session always required to accomplish this?" New topic
Author

is session always required to accomplish this?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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.
Hemant Sharma
Greenhorn

Joined: Feb 01, 2007
Posts: 23
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.


Thanks & Regards,<br />Hemant K. Sharma
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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

Joined: Oct 11, 2004
Posts: 3830
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is session always required to accomplish this?