You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Amol Ghotankar <gh...@gmail.com> on 2010/06/17 07:19:04 UTC

Action redirect back to called actions

Hello.

I am using struts 2.0.x and facing one issue mentioned below.

I have actions x, y, z from these three actions I can call action A.

Now what i want is whichever action calls A success of A must redirect to
called action.

x---> A ---> x

y---> A ---> y

z---> A ---> z

But I also do not want to use static binding here and it must be
automatically done for some action means if tomorrow I decide

n---> A ---> n, it must work without any changes.

Can I write such result type or something from where I can get the called
action from value stack etc......

Please help me on the same.

Regards,


Amol Ghotankar
cursivetech.com

Re: Action redirect back to called actions

Posted by Greg Lindholm <gr...@gmail.com>.
Well you are need to track and supply which action name you want the
redirect to go to.

Here is a handy tip; to get the current action name from your action
class you can add a method like this:

    public String getActionName()
    {
        ActionContext context = ActionContext.getContext();

        String actionName = context.getName();

        return actionName;
    }



On Thu, Jun 17, 2010 at 9:55 AM, Amol Ghotankar <gh...@gmail.com> wrote:
> Dear Greg,
>
> I understood this of how to redirect to next action.
>
> But I want to get the previous action from the context which called this
> action.
>
> For eg.
>
> LoginAction calls LoadHomeAction, so can I get the details of which action
> called LoadHomeAction in it.
>
> Inshort *can the called Action get the details of calling action directly
> from the context *or value stack etc..
>
> Please guide me.
>
> With regards,
>
>
> Amol Ghotankar
>
> cursivetech.com
>
> On Thu, Jun 17, 2010 at 7:17 PM, Amol Ghotankar <gh...@gmail.com>wrote:
>
>> Dear Greg.
>>
>> Thanks for the information.
>>
>> Is this an inbuilt variable or we need to define it somewhere in the
>> calling action.
>>
>> Can we also the namespace of the calling action in the called action
>> directly.
>>
>>
>> Regards,
>>
>> Amol Ghotankar
>>
>> cursivetech.com
>>
>> On Thu, Jun 17, 2010 at 6:31 PM, Greg Lindholm <gr...@gmail.com>wrote:
>>
>>> You can configure a dynamic result like this:
>>>
>>>      <result type="redirectAction">
>>>        <param name="actionName">${nextAction}</param>
>>>      </result>
>>>
>>> In your action class you would then need a method  "String
>>> getNextAction()" that returns the next action name.
>>>
>>>
>>> On Thu, Jun 17, 2010 at 1:19 AM, Amol Ghotankar <gh...@gmail.com>
>>> wrote:
>>> > Hello.
>>> >
>>> > I am using struts 2.0.x and facing one issue mentioned below.
>>> >
>>> > I have actions x, y, z from these three actions I can call action A.
>>> >
>>> > Now what i want is whichever action calls A success of A must redirect
>>> to
>>> > called action.
>>> >
>>> > x---> A ---> x
>>> >
>>> > y---> A ---> y
>>> >
>>> > z---> A ---> z
>>> >
>>> > But I also do not want to use static binding here and it must be
>>> > automatically done for some action means if tomorrow I decide
>>> >
>>> > n---> A ---> n, it must work without any changes.
>>> >
>>> > Can I write such result type or something from where I can get the
>>> called
>>> > action from value stack etc......
>>> >
>>> > Please help me on the same.
>>> >
>>> > Regards,
>>> >
>>> >
>>> > Amol Ghotankar
>>> > cursivetech.com
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Action redirect back to called actions

Posted by Amol Ghotankar <gh...@gmail.com>.
Dear Greg,

I understood this of how to redirect to next action.

But I want to get the previous action from the context which called this
action.

For eg.

LoginAction calls LoadHomeAction, so can I get the details of which action
called LoadHomeAction in it.

Inshort *can the called Action get the details of calling action directly
from the context *or value stack etc..

Please guide me.

With regards,


Amol Ghotankar

cursivetech.com

On Thu, Jun 17, 2010 at 7:17 PM, Amol Ghotankar <gh...@gmail.com>wrote:

> Dear Greg.
>
> Thanks for the information.
>
> Is this an inbuilt variable or we need to define it somewhere in the
> calling action.
>
> Can we also the namespace of the calling action in the called action
> directly.
>
>
> Regards,
>
> Amol Ghotankar
>
> cursivetech.com
>
> On Thu, Jun 17, 2010 at 6:31 PM, Greg Lindholm <gr...@gmail.com>wrote:
>
>> You can configure a dynamic result like this:
>>
>>      <result type="redirectAction">
>>        <param name="actionName">${nextAction}</param>
>>      </result>
>>
>> In your action class you would then need a method  "String
>> getNextAction()" that returns the next action name.
>>
>>
>> On Thu, Jun 17, 2010 at 1:19 AM, Amol Ghotankar <gh...@gmail.com>
>> wrote:
>> > Hello.
>> >
>> > I am using struts 2.0.x and facing one issue mentioned below.
>> >
>> > I have actions x, y, z from these three actions I can call action A.
>> >
>> > Now what i want is whichever action calls A success of A must redirect
>> to
>> > called action.
>> >
>> > x---> A ---> x
>> >
>> > y---> A ---> y
>> >
>> > z---> A ---> z
>> >
>> > But I also do not want to use static binding here and it must be
>> > automatically done for some action means if tomorrow I decide
>> >
>> > n---> A ---> n, it must work without any changes.
>> >
>> > Can I write such result type or something from where I can get the
>> called
>> > action from value stack etc......
>> >
>> > Please help me on the same.
>> >
>> > Regards,
>> >
>> >
>> > Amol Ghotankar
>> > cursivetech.com
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

Re: Action redirect back to called actions

Posted by Amol Ghotankar <gh...@gmail.com>.
Dear Greg.

Thanks for the information.

Is this an inbuilt variable or we need to define it somewhere in the calling
action.

Can we also the namespace of the calling action in the called action
directly.

Regards,

Amol Ghotankar

cursivetech.com

On Thu, Jun 17, 2010 at 6:31 PM, Greg Lindholm <gr...@gmail.com>wrote:

> You can configure a dynamic result like this:
>
>      <result type="redirectAction">
>        <param name="actionName">${nextAction}</param>
>      </result>
>
> In your action class you would then need a method  "String
> getNextAction()" that returns the next action name.
>
>
> On Thu, Jun 17, 2010 at 1:19 AM, Amol Ghotankar <gh...@gmail.com>
> wrote:
> > Hello.
> >
> > I am using struts 2.0.x and facing one issue mentioned below.
> >
> > I have actions x, y, z from these three actions I can call action A.
> >
> > Now what i want is whichever action calls A success of A must redirect to
> > called action.
> >
> > x---> A ---> x
> >
> > y---> A ---> y
> >
> > z---> A ---> z
> >
> > But I also do not want to use static binding here and it must be
> > automatically done for some action means if tomorrow I decide
> >
> > n---> A ---> n, it must work without any changes.
> >
> > Can I write such result type or something from where I can get the called
> > action from value stack etc......
> >
> > Please help me on the same.
> >
> > Regards,
> >
> >
> > Amol Ghotankar
> > cursivetech.com
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Action redirect back to called actions

Posted by Greg Lindholm <gr...@gmail.com>.
You can configure a dynamic result like this:

      <result type="redirectAction">
        <param name="actionName">${nextAction}</param>
      </result>

In your action class you would then need a method  "String
getNextAction()" that returns the next action name.


On Thu, Jun 17, 2010 at 1:19 AM, Amol Ghotankar <gh...@gmail.com> wrote:
> Hello.
>
> I am using struts 2.0.x and facing one issue mentioned below.
>
> I have actions x, y, z from these three actions I can call action A.
>
> Now what i want is whichever action calls A success of A must redirect to
> called action.
>
> x---> A ---> x
>
> y---> A ---> y
>
> z---> A ---> z
>
> But I also do not want to use static binding here and it must be
> automatically done for some action means if tomorrow I decide
>
> n---> A ---> n, it must work without any changes.
>
> Can I write such result type or something from where I can get the called
> action from value stack etc......
>
> Please help me on the same.
>
> Regards,
>
>
> Amol Ghotankar
> cursivetech.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org