On Wednesday 22 April 2009 00:36:36 satyanarayana katta wrote:
> Hi All,
> I have a Action class
>
> class BaseAction extends ActionSupport {
> private Sting data;
>
> public void getData() {
> return this.data;
> }
>
> public String setData(String data){
> this.data = data;
> }
> }
>
> class Action extends BaseAction{
> public String execute() throws Exception {
> System.out.println(getData());
> setData("abc");
> return "chain";
> }
>
> public String executeChain() throws Exception {
> System.out.println(getData());
> return "success"
> }
> }
>
> xml configuration:
>
> <action name="test" class="Action">
> <result name="chain">test2</result>
> </action>
>
> <action name="test2" class="Action" method="execute1">
> <result name="chain"></result>
> </action>
>
>
>
> http://localhost:8080/test/test.action?data=ball
>
> Output of execute: ball
> Output of execute1: ball
>
> I am expecting the out of execute1 as "abc"
>
> Am I missing something please help me resolve the issue.
>
> Rgds,
>
> Satya
The configuration of test2 points to method execute1, but your action has
executeChain(). I assume that's a typo. My (somewhat educated) guess is that
when you chain to the next action, even though it is the same class, a new
instance is created. In the new instance, setData(String) is never called
since it is only called in the execute method.
-Wes
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]