views:

3557

answers:

3

I'm successfully using a redirect-action for one of my struts2 mapping files as follows:

<action name="setAsCurrentCart" class="com.fmp.MyAction">
  <result name="success" type="redirect-action">
    <param name="actionName">myOtherAction</param>
    <param name="foo">${foo}</param>
  </result>
  <interceptor-ref name="defaultComponentStack"/>
</action>

Here's what I want to do though:

<action name="setAsCurrentCart" class="com.fmp.MyAction">
  <result name="success" type="redirect-action">
    <param name="actionName">myOtherAction</param>
    <param name="${dynamicParameterName}">${dynamicParameterValue}</param>
  </result>
  <interceptor-ref name="defaultComponentStack"/>
</action>

In other words, I want the name of the parameter that I'm passing to be dynamic. Does anyone know if this is possible?

A: 

could you do this instead?

<action name="setAsCurrentCart" class="com.fmp.MyAction">
   <result name="success" type="redirect-action">
      <param name="actionName">myOtherAction</param>
      <param name="paramName">${dynamicParameterName}</param>
      <param name="paramValue">${dynamicParameterValue}</param>
   </result>
</action>
Brad Cupit
+2  A: 

Actually, that doesn't work. However, I was able to get this working doing the following:

<action name="setAsCurrentCart" class="com.fmp.MyAction">
   <result name="success" type="redirect-action">
      <param name="actionName">myOtherAction</param>
      <param name="${dynamicParameterName}">${dynamicParameterValue}</param>
   </result>
</action>

I had just assumed it wouldn't work.

fmpdmb
A: 

Hi, But how you use the parameter "dynamicParameterName" in action?

Thank you. A greeting.

alvaro