You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by srinivasch <sr...@gmail.com> on 2008/09/18 19:06:05 UTC

Struts 2: How can we save the parameters if we do redirect and not redirect-action

Hi,

   My issue goes like this, I have a summary page which comes for a search
result, and the user clicks to see summary of any record from the result. So
all the search parameters are existing in the URL. And when we further hit
edit link of the summary record, and again when the user hits cancel or
save, the URL parameters which were forwarded to the summary page wont
exist. I would like to retain the parameters. Appreciate your quick response

Here is the snippet of my struts config how I used the result

<result name="return-summary" type="redirect">
	            /view.action?linID=${linID}
</result>
-- 
View this message in context: http://www.nabble.com/Struts-2%3A-How-can-we-save-the-parameters-if-we-do-redirect-and-not-redirect-action-tp19557514p19557514.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2: How can we save the parameters if we do redirect and not redirect-action

Posted by srinivasch <sr...@gmail.com>.
Where did you set the session with the parameterMap in the
servletRedirectResult.java or ?

daveck wrote:
> 
> I ended up solving a similiar problem using an Interceptor and saving the
> parameter Map to the session.
> 
> session.setAttribute("input_params", request.getParameterMap();
> 
> Then in my action I implemented SessionAware and utililized BeanUtils from
> Jakarta Commons to re-populate the properties in my action class.
> 
> this.setRequestMap((Map)this.getSession().get("input_parms"));
> BeanUtils.populate(this, this.getRequestMap();
> 
> Hope this helps.
> 
> 
> srinivasch wrote:
>> 
>> Hi,
>> 
>>    My issue goes like this, I have a summary page which comes for a
>> search result, and the user clicks to see summary of any record from the
>> result. So all the search parameters are existing in the URL. And when we
>> further hit edit link of the summary record, and again when the user hits
>> cancel or save, the URL parameters which were forwarded to the summary
>> page wont exist. I would like to retain the parameters. Appreciate your
>> quick response
>> 
>> Here is the snippet of my struts config how I used the result
>> 
>> <result name="return-summary" type="redirect">
>> 	            /view.action?linID=${linID}
>> </result>
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2%3A-How-can-we-save-the-parameters-if-we-do-redirect-and-not-redirect-action-tp19557514p19557837.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2: How can we save the parameters if we do redirect and not redirect-action

Posted by daveck <de...@holstein.com>.
I ended up solving a similiar problem using an Interceptor and saving the
parameter Map to the session.

session.setAttribute("input_params", request.getParameterMap();

Then in my action I implemented SessionAware and utililized BeanUtils from
Jakarta Commons to re-populate the properties in my action class.

this.setRequestMap((Map)this.getSession().get("input_parms"));
BeanUtils.populate(this, this.getRequestMap();

Hope this helps.


srinivasch wrote:
> 
> Hi,
> 
>    My issue goes like this, I have a summary page which comes for a search
> result, and the user clicks to see summary of any record from the result.
> So all the search parameters are existing in the URL. And when we further
> hit edit link of the summary record, and again when the user hits cancel
> or save, the URL parameters which were forwarded to the summary page wont
> exist. I would like to retain the parameters. Appreciate your quick
> response
> 
> Here is the snippet of my struts config how I used the result
> 
> <result name="return-summary" type="redirect">
> 	            /view.action?linID=${linID}
> </result>
> 

-- 
View this message in context: http://www.nabble.com/Struts-2%3A-How-can-we-save-the-parameters-if-we-do-redirect-and-not-redirect-action-tp19557514p19557768.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2: How can we save the parameters if we do redirect and not redirect-action

Posted by DE...@holstein.com.
Yes.  I should have mentioned that I used a marker interface.




Dave Newton <ne...@yahoo.com> 
09/18/2008 02:30 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
Struts Users Mailing List <us...@struts.apache.org>
cc

Subject
Re: Struts 2: How can we save the parameters if we do redirect and not 
redirect-action







There's no extra code in the action. The code is in the interceptor. The 
action (I'm assuming) implements a marker interface to inform the 
interceptor that it should put the request parameters into the session.

IMO doing this in a custom result is the wrong way to go about it, for 
several reasons; one is that the interceptor approach works no matter what 
result type you end up using.

Dave





This e-mail and any files transmitted with it are confidential and intended
solely for the use of the individual(s) or entity to whom they are addressed.
 If you receive this e-mail in error please notify postmaster@holstein.com.


Re: Struts 2: How can we save the parameters if we do redirect and not redirect-action

Posted by Dave Newton <ne...@yahoo.com>.
--- On Thu, 9/18/08, srinivasch wrote:
> OK, I changed my view, i would go ahead and extend 
> ServletRedirectResult and try to include the request 
> parameters just like how ServletActionRedirectResult 
> and URL component try to do. That way it would
> be consistent. Your solution is also good though, but I
> dont like to have extra code in my action since it will 
> complicate my logic.

There's no extra code in the action. The code is in the interceptor. The action (I'm assuming) implements a marker interface to inform the interceptor that it should put the request parameters into the session.

IMO doing this in a custom result is the wrong way to go about it, for several reasons; one is that the interceptor approach works no matter what result type you end up using.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2: How can we save the parameters if we do redirect and not redirect-action

Posted by srinivasch <sr...@gmail.com>.
   OK, I changed my view, i would go ahead and extend ServletRedirectResult
and try to include the request parameters just like how
ServletActionRedirectResult and URL component try to do. That way it would
be consistent. Your solution is also good though, but I dont like to have
extra code in my action since it will complicate my logic.


daveck wrote:
> 
> 
> 
> In an interceptor that my action implemented.
> 
> session.setAttribute("PARMS", request.getParameterMap());
> 
> 
> 
>>  Where did you set the session with the parameterMap in the
>>  servletRedirectResult.java or ?
> 
> 
> 
> This e-mail and any files transmitted with it are confidential and
> intended
> solely for the use of the individual(s) or entity to whom they are
> addressed.
>  If you receive this e-mail in error please notify
> postmaster@holstein.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2%3A-How-can-we-save-the-parameters-if-we-do-redirect-and-not-redirect-action-tp19557514p19558657.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org