You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mohit Gupta <mo...@gmail.com> on 2013/03/02 09:45:58 UTC

Not setting instance member value in destination action using action chaining?

This is my struts 2 flow where i am using action chaining

JSP--->Action1--->Action2--->ResultJsp

With action chaining , my understanding is that request is forwarded from
action1 to action2.So if i pass some parameter from action1 to action 2
it should be set in new action instance variable(/value stack created for
new action).But its not happening

Below is my code in action1


    @Result(name = "displayEmployee",type = "chain",
            params = {
                "namespace", "/employee",
                "actionName", "Employee-lookup!search",
                "empMode", "true"

            })


    @Action("display-employee!displayEmployee")
      public String displayEmployee() {
        return "displayEmployee";
      }

Now in Action 2 i.e display-employee , i have boolean property with name
empMode. But i get the value as false though i should get it true
because i am passing it as attribute in result annotation. As my
understanding in action chaining, all request paramaters are
forwarded from action1 to action2. Basically new value stack is created for
action2 which contains the variables which were present
in action1. So why value true is not set for empMode property in action 2?

Re: Not setting instance member value in destination action using action chaining?

Posted by Mohit Gupta <mo...@gmail.com>.
oops i missed  ur's todays answer on so. Thanx. Its clear now

On Sat, Mar 2, 2013 at 3:01 PM, Ken McWilliams <ke...@gmail.com>wrote:

> This was already addressed on SO:
>
> http://stackoverflow.com/questions/15159827/not-setting-instance-member-value-in-destination-action-using-action-chaining
> We explained that chain was a result and that the chaining interceptor did
> not process additional parameters and so they would not be included, if you
> want empMode to be true then have it as a property of the action and set
> it's value to true before chaining and the comments also covered it is
> generally best to avoid chain if possible.
>
> What is unclear?
>
>
> On Sat, Mar 2, 2013 at 1:45 AM, Mohit Gupta <mo...@gmail.com> wrote:
>
> > This is my struts 2 flow where i am using action chaining
> >
> > JSP--->Action1--->Action2--->ResultJsp
> >
> > With action chaining , my understanding is that request is forwarded from
> > action1 to action2.So if i pass some parameter from action1 to action 2
> > it should be set in new action instance variable(/value stack created for
> > new action).But its not happening
> >
> > Below is my code in action1
> >
> >
> >     @Result(name = "displayEmployee",type = "chain",
> >             params = {
> >                 "namespace", "/employee",
> >                 "actionName", "Employee-lookup!search",
> >                 "empMode", "true"
> >
> >             })
> >
> >
> >     @Action("display-employee!displayEmployee")
> >       public String displayEmployee() {
> >         return "displayEmployee";
> >       }
> >
> > Now in Action 2 i.e display-employee , i have boolean property with name
> > empMode. But i get the value as false though i should get it true
> > because i am passing it as attribute in result annotation. As my
> > understanding in action chaining, all request paramaters are
> > forwarded from action1 to action2. Basically new value stack is created
> for
> > action2 which contains the variables which were present
> > in action1. So why value true is not set for empMode property in action
> 2?
> >
>

Re: Not setting instance member value in destination action using action chaining?

Posted by Mohit Gupta <mo...@gmail.com>.
My guess is Action chaining is meant for forwarding the request to struts 2
actions only ,not to legacy actions. Right? If yes, How can i forward the
request to non struts 2 action  from struts 2 action using result
annotation.

My understanding of action chaining after looking the source code of
ActionChainResult.java is that new Action context  is created  where value
stack and parameter map created for new action will contain the values from
valueStack/Parameter map for previous action value stack.(Probably request
attributes set in previous action wont be available inside in new action,
is that correct)?

On Sat, Mar 2, 2013 at 3:39 PM, Ken McWilliams <ke...@gmail.com>wrote:

> Not sure what you mean.
>
>
> On Sat, Mar 2, 2013 at 2:58 AM, Mohit Gupta <mo...@gmail.com> wrote:
>
> > Ken one more thing can we use action chaining to forward the request to
> > action which is not struts 2. i know action chaining shoukld be
> discourged
> > but just exploring the options.
> >
> > On Sat, Mar 2, 2013 at 3:01 PM, Ken McWilliams <ken.mcwilliams@gmail.com
> > >wrote:
> >
> > > This was already addressed on SO:
> > >
> > >
> >
> http://stackoverflow.com/questions/15159827/not-setting-instance-member-value-in-destination-action-using-action-chaining
> > > We explained that chain was a result and that the chaining interceptor
> > did
> > > not process additional parameters and so they would not be included, if
> > you
> > > want empMode to be true then have it as a property of the action and
> set
> > > it's value to true before chaining and the comments also covered it is
> > > generally best to avoid chain if possible.
> > >
> > > What is unclear?
> > >
> > >
> > > On Sat, Mar 2, 2013 at 1:45 AM, Mohit Gupta <mo...@gmail.com>
> wrote:
> > >
> > > > This is my struts 2 flow where i am using action chaining
> > > >
> > > > JSP--->Action1--->Action2--->ResultJsp
> > > >
> > > > With action chaining , my understanding is that request is forwarded
> > from
> > > > action1 to action2.So if i pass some parameter from action1 to
> action 2
> > > > it should be set in new action instance variable(/value stack created
> > for
> > > > new action).But its not happening
> > > >
> > > > Below is my code in action1
> > > >
> > > >
> > > >     @Result(name = "displayEmployee",type = "chain",
> > > >             params = {
> > > >                 "namespace", "/employee",
> > > >                 "actionName", "Employee-lookup!search",
> > > >                 "empMode", "true"
> > > >
> > > >             })
> > > >
> > > >
> > > >     @Action("display-employee!displayEmployee")
> > > >       public String displayEmployee() {
> > > >         return "displayEmployee";
> > > >       }
> > > >
> > > > Now in Action 2 i.e display-employee , i have boolean property with
> > name
> > > > empMode. But i get the value as false though i should get it true
> > > > because i am passing it as attribute in result annotation. As my
> > > > understanding in action chaining, all request paramaters are
> > > > forwarded from action1 to action2. Basically new value stack is
> created
> > > for
> > > > action2 which contains the variables which were present
> > > > in action1. So why value true is not set for empMode property in
> action
> > > 2?
> > > >
> > >
> >
>

Re: Not setting instance member value in destination action using action chaining?

Posted by Ken McWilliams <ke...@gmail.com>.
Not sure what you mean.


On Sat, Mar 2, 2013 at 2:58 AM, Mohit Gupta <mo...@gmail.com> wrote:

> Ken one more thing can we use action chaining to forward the request to
> action which is not struts 2. i know action chaining shoukld be discourged
> but just exploring the options.
>
> On Sat, Mar 2, 2013 at 3:01 PM, Ken McWilliams <ken.mcwilliams@gmail.com
> >wrote:
>
> > This was already addressed on SO:
> >
> >
> http://stackoverflow.com/questions/15159827/not-setting-instance-member-value-in-destination-action-using-action-chaining
> > We explained that chain was a result and that the chaining interceptor
> did
> > not process additional parameters and so they would not be included, if
> you
> > want empMode to be true then have it as a property of the action and set
> > it's value to true before chaining and the comments also covered it is
> > generally best to avoid chain if possible.
> >
> > What is unclear?
> >
> >
> > On Sat, Mar 2, 2013 at 1:45 AM, Mohit Gupta <mo...@gmail.com> wrote:
> >
> > > This is my struts 2 flow where i am using action chaining
> > >
> > > JSP--->Action1--->Action2--->ResultJsp
> > >
> > > With action chaining , my understanding is that request is forwarded
> from
> > > action1 to action2.So if i pass some parameter from action1 to action 2
> > > it should be set in new action instance variable(/value stack created
> for
> > > new action).But its not happening
> > >
> > > Below is my code in action1
> > >
> > >
> > >     @Result(name = "displayEmployee",type = "chain",
> > >             params = {
> > >                 "namespace", "/employee",
> > >                 "actionName", "Employee-lookup!search",
> > >                 "empMode", "true"
> > >
> > >             })
> > >
> > >
> > >     @Action("display-employee!displayEmployee")
> > >       public String displayEmployee() {
> > >         return "displayEmployee";
> > >       }
> > >
> > > Now in Action 2 i.e display-employee , i have boolean property with
> name
> > > empMode. But i get the value as false though i should get it true
> > > because i am passing it as attribute in result annotation. As my
> > > understanding in action chaining, all request paramaters are
> > > forwarded from action1 to action2. Basically new value stack is created
> > for
> > > action2 which contains the variables which were present
> > > in action1. So why value true is not set for empMode property in action
> > 2?
> > >
> >
>

Re: Not setting instance member value in destination action using action chaining?

Posted by Mohit Gupta <mo...@gmail.com>.
Ken one more thing can we use action chaining to forward the request to
action which is not struts 2. i know action chaining shoukld be discourged
but just exploring the options.

On Sat, Mar 2, 2013 at 3:01 PM, Ken McWilliams <ke...@gmail.com>wrote:

> This was already addressed on SO:
>
> http://stackoverflow.com/questions/15159827/not-setting-instance-member-value-in-destination-action-using-action-chaining
> We explained that chain was a result and that the chaining interceptor did
> not process additional parameters and so they would not be included, if you
> want empMode to be true then have it as a property of the action and set
> it's value to true before chaining and the comments also covered it is
> generally best to avoid chain if possible.
>
> What is unclear?
>
>
> On Sat, Mar 2, 2013 at 1:45 AM, Mohit Gupta <mo...@gmail.com> wrote:
>
> > This is my struts 2 flow where i am using action chaining
> >
> > JSP--->Action1--->Action2--->ResultJsp
> >
> > With action chaining , my understanding is that request is forwarded from
> > action1 to action2.So if i pass some parameter from action1 to action 2
> > it should be set in new action instance variable(/value stack created for
> > new action).But its not happening
> >
> > Below is my code in action1
> >
> >
> >     @Result(name = "displayEmployee",type = "chain",
> >             params = {
> >                 "namespace", "/employee",
> >                 "actionName", "Employee-lookup!search",
> >                 "empMode", "true"
> >
> >             })
> >
> >
> >     @Action("display-employee!displayEmployee")
> >       public String displayEmployee() {
> >         return "displayEmployee";
> >       }
> >
> > Now in Action 2 i.e display-employee , i have boolean property with name
> > empMode. But i get the value as false though i should get it true
> > because i am passing it as attribute in result annotation. As my
> > understanding in action chaining, all request paramaters are
> > forwarded from action1 to action2. Basically new value stack is created
> for
> > action2 which contains the variables which were present
> > in action1. So why value true is not set for empMode property in action
> 2?
> >
>

Re: Not setting instance member value in destination action using action chaining?

Posted by Ken McWilliams <ke...@gmail.com>.
This was already addressed on SO:
http://stackoverflow.com/questions/15159827/not-setting-instance-member-value-in-destination-action-using-action-chaining
We explained that chain was a result and that the chaining interceptor did
not process additional parameters and so they would not be included, if you
want empMode to be true then have it as a property of the action and set
it's value to true before chaining and the comments also covered it is
generally best to avoid chain if possible.

What is unclear?


On Sat, Mar 2, 2013 at 1:45 AM, Mohit Gupta <mo...@gmail.com> wrote:

> This is my struts 2 flow where i am using action chaining
>
> JSP--->Action1--->Action2--->ResultJsp
>
> With action chaining , my understanding is that request is forwarded from
> action1 to action2.So if i pass some parameter from action1 to action 2
> it should be set in new action instance variable(/value stack created for
> new action).But its not happening
>
> Below is my code in action1
>
>
>     @Result(name = "displayEmployee",type = "chain",
>             params = {
>                 "namespace", "/employee",
>                 "actionName", "Employee-lookup!search",
>                 "empMode", "true"
>
>             })
>
>
>     @Action("display-employee!displayEmployee")
>       public String displayEmployee() {
>         return "displayEmployee";
>       }
>
> Now in Action 2 i.e display-employee , i have boolean property with name
> empMode. But i get the value as false though i should get it true
> because i am passing it as attribute in result annotation. As my
> understanding in action chaining, all request paramaters are
> forwarded from action1 to action2. Basically new value stack is created for
> action2 which contains the variables which were present
> in action1. So why value true is not set for empMode property in action 2?
>