You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Halil Ağın <ha...@gmail.com> on 2009/06/25 16:54:07 UTC

problem in parameter passing to chained action with the same parameter name

Hello List;

I am doing some expreiment on chaining action. I want to pass a request
parameter to my chained action with the same name of parameter.

I call the action as http://localhost:8080/action3.action?param=10
action3 decrease the param value by 1 and return the chained result. the
chained action should be called as
http://localhost:8080/action3.action?param=9

but it is called as http://localhost:8080/action3.action?param=10

if i change the name of request parameter, everythin is ok. But i want to
call the chained action with the same request parameter. But i could not
succeed.

How can i do that?

thank you,


I pasted the related code parts below.


There are two action below:
---------------------------------------------struts.xml----------------------------------------------------------
<action name="action2" class="tr.com.herekol.action.chainaction.Action2">
            <result name="success">/jsp/sample2.jsp</result>
        </action>

        <action name="action3"
class="tr.com.herekol.action.chainaction.ChainAction">
            <result name="chain" type="chain">
                <param name="actionName">${actionName}</param>
                <param name="namespace">${namespace}</param>
                <param name="param">${param}</param>
            </result>
            <result name="success" type="redirect">/action2.action</result>
        </action>
 ---------------------------------------------struts.xml----------------------------------------------------------

Here are execute methods of Action2 and ChainAction

---------------------------------------------action2.execute----------------------------------------------------------
public String execute(){
        if (servletRequest.getParameter("param")!=null)

System.err.println("-->>"+servletRequest.getParameter("param").toString());

        return "success";
    }

---------------------------------------------action2.execute----------------------------------------------------------



---------------------------------------------action3.execute----------------------------------------------------------
public String execute(){

        actionName="action2";
        namespace="/";

        if (servletRequest.getParameter("param")==null)
            return "success";

        System.err.println(servletRequest.getParameter("param").toString());

        int pr = Integer.parseInt(
servletRequest.getParameter("param").toString());

        if (pr==0)
            return "success";
        pr--;
        param=pr+"";


        return "chain";
    }
---------------------------------------------action3.execute----------------------------------------------------------