struts.xml - redirect-action, OGNL for Parameters and Attributes?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

struts.xml - redirect-action, OGNL for Parameters and Attributes?

masotime
Hi,

I presently have the following syntax in my struts.xml configuration file:-

<action name="someaction"
        class="someclass.someaction"
                method="somemethod">
        <result name="success" type="redirect-action">                           
            <param name="actionName">someotheraction</param>
            <param name="Req">${Request.customerId}</param>
            <param name="req">${request.customerId}</param>
            <param name="Param">${Parameters.customerId}</param>
            <param name="param">${parameters.customerId}</param>
            <param name="param2">${param.customerId}</param>
            <param name="customerId">${customerId}</param>    
        </result>
</action>               

The customerId is defined in the POST to someaction, but no matter what I do, I cannot get Struts to retrieve the customerId from the Request Attribute or Request Parameters in the POST data to someaction (the parameters Req, req, Param, param, param2 all show up as blank strings) - I have to manually define a customerId property in the someaction class and only ${customerId} works.  Is there some way to use parameters in the POST to someaction or Request attributes set in someaction?
Reply | Threaded
Open this post in threaded view
|

Re: struts.xml - redirect-action, OGNL for Parameters and Attributes?

vinodkashyap
Administrator
Hi

First of all you add this line
       
<param name="namespace">something here</param>
<param name="parse">true</param>

parse = true helps your parameters to parse

Reply | Threaded
Open this post in threaded view
|

Re: struts.xml - redirect-action, OGNL for Parameters and Attributes?

masotime
Hi, thanks for the response.

Actually the code written as

<action name="someaction"
        class="someclass.someaction"
        method="somemethod">
        <result name="success" type="redirect-action">    
            <param name="actionName">someotheraction</param>
            <param name="customerId">${customerId}</param>    
        </result>
</action>

Works perfectly fine, parse is "true" by default, and customerId has to be a property with get and set methods in someaction.  My real concern is whether or not I can use the parameters passed in to someaction to be passed on to someotheraction directly, rather than via the proxy of having a property in someaction.
Reply | Threaded
Open this post in threaded view
|

Re: struts.xml - redirect-action, OGNL for Parameters and Attributes?

Droopy
Hi,

this is the way

<action name="someaction" class="someclass.someaction" method="somemethod">
        <result name="success" type="redirect-action">
            <param name="actionName">someotheraction</param>
            <param name="customerId">${#parameters['customerId'][0]}</param>
        </result>
</action>
Reply | Threaded
Open this post in threaded view
|

Re: struts.xml - redirect-action, OGNL for Parameters and Attributes?

Pragya
Great!!! I have been looking for the solution for quite a long time. Thanks! It is PERFECT!!