You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Edward Song <ed...@nuhorizons.com> on 2009/03/10 16:52:47 UTC

Convention Plugin and Action Chaining

Hi all,

This question concerns the Convention Plugin, specifically in regards to
Action Chaining.

I am using Struts 2.1.6

I have the following package structure.

 com.company.web.actions.administrators.GetAction
(/administrators/get)
 com.company.web.actions.administrators.SaveAction
(/administrators/save)

After SaveAction.execute(), I wanted to use action chaining and forward
to GetAction.execute().

I was able to get this to work via annotations in my SaveAction class.  The
execute() method returns ActionSupport.SUCCESS.

@Results({

@Result(name=ActionSupport.*SUCCESS*, type="chain", location="get")

})
However, it seems through the examples, that annotations may not be required
for simple action chaining.
Can we return an action name, effectively chainining the actions together?
I had attempted returning "get" in my SaveAction.execute(), thinking that it
would action chain GetAction.
The result was forwarded to my /WEB-INF/content/administrators/get.jsp, but
never actually ran GetAction.execute() .

Any idea as to what my SaveAction.execute() method should return to
accomplish simple action chaining without the annotation above?

Thank you in advance.

Re: Convention Plugin and Action Chaining

Posted by Edward Song <ed...@nuhorizons.com>.
Thanks Musachy, I fully understand now.  I appreciate your help.

On Tue, Mar 10, 2009 at 1:54 PM, Musachy Barroso <mu...@gmail.com> wrote:

> If the result is "get" and the source action is target is "save", then
> the "target" action has to be "save-get" (yours is "get").
>
> musachy
>
> On Tue, Mar 10, 2009 at 1:42 PM, Edward Song <ed...@nuhorizons.com>
> wrote:
> > Thanks Musachy for your prompt response.
> >
> > Makes total sense.
> >
> > However, I now tried the following based on your reply....
> >
> > GetAction.execute() returns ActionSupport.SUCCESS.
> > forwards to....
> > get-success.jsp  (renamed get.jsp, so that it would not be found in the
> > instance below)
> >
> > SaveAction.execute() returns "get"  (in hopes of chaining GetAction)
> >
> > However, after SaveAction.execute(), I get an exception stating that the
> > result "get" is not found.
> > "No result defined for action com.company.web.actions.SaveAction and
> result
> > get"
> >
> > Note that, both of these guys are in the same package, and therefore in
> the
> > same namespace.
> > Through the config-browser, I did verify that "get" is not one of the
> listed
> > result types not found.
> >
> > Ed
> >
> >
> >
> > On Tue, Mar 10, 2009 at 12:19 PM, Musachy Barroso <mu...@gmail.com>
> wrote:
> >
> >> The problem in your case, is that Convention tries to find
> >> "get-get.jsp" and then tries "get.jsp", which it will find, so it will
> >> never chain to the action, but rather dispatch to the jsp. Chaining
> >> only works when no result is found.
> >>
> >> musahcy
> >>
> >> On Tue, Mar 10, 2009 at 12:12 PM, Musachy Barroso <mu...@gmail.com>
> >> wrote:
> >> > Yes, you can chain actions if they are in the same package:
> >> >
> >> >
> >>
> http://cwiki.apache.org/WW/convention-plugin.html#ConventionPlugin-Chaining
> >> >
> >> > musachy
> >> >
> >> > On Tue, Mar 10, 2009 at 11:52 AM, Edward Song
> >> > <ed...@nuhorizons.com> wrote:
> >> >> Hi all,
> >> >>
> >> >> This question concerns the Convention Plugin, specifically in regards
> to
> >> >> Action Chaining.
> >> >>
> >> >> I am using Struts 2.1.6
> >> >>
> >> >> I have the following package structure.
> >> >>
> >> >>  com.company.web.actions.administrators.GetAction
> >> >> (/administrators/get)
> >> >>  com.company.web.actions.administrators.SaveAction
> >> >> (/administrators/save)
> >> >>
> >> >> After SaveAction.execute(), I wanted to use action chaining and
> forward
> >> >> to GetAction.execute().
> >> >>
> >> >> I was able to get this to work via annotations in my SaveAction
> class.
> >>  The
> >> >> execute() method returns ActionSupport.SUCCESS.
> >> >>
> >> >> @Results({
> >> >>
> >> >> @Result(name=ActionSupport.*SUCCESS*, type="chain", location="get")
> >> >>
> >> >> })
> >> >> However, it seems through the examples, that annotations may not be
> >> required
> >> >> for simple action chaining.
> >> >> Can we return an action name, effectively chainining the actions
> >> together?
> >> >> I had attempted returning "get" in my SaveAction.execute(), thinking
> >> that it
> >> >> would action chain GetAction.
> >> >> The result was forwarded to my
> /WEB-INF/content/administrators/get.jsp,
> >> but
> >> >> never actually ran GetAction.execute() .
> >> >>
> >> >> Any idea as to what my SaveAction.execute() method should return to
> >> >> accomplish simple action chaining without the annotation above?
> >> >>
> >> >> Thank you in advance.
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >> >
> >>
> >>
> >>
> >> --
> >> "Hey you! Would you help me to carry the stone?" Pink Floyd
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>
>
>
> --
>  "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Regards,
Edward Song
Java Web Developer
631-396-5000 x306

Re: Convention Plugin and Action Chaining

Posted by Musachy Barroso <mu...@gmail.com>.
If the result is "get" and the source action is target is "save", then
the "target" action has to be "save-get" (yours is "get").

musachy

On Tue, Mar 10, 2009 at 1:42 PM, Edward Song <ed...@nuhorizons.com> wrote:
> Thanks Musachy for your prompt response.
>
> Makes total sense.
>
> However, I now tried the following based on your reply....
>
> GetAction.execute() returns ActionSupport.SUCCESS.
> forwards to....
> get-success.jsp  (renamed get.jsp, so that it would not be found in the
> instance below)
>
> SaveAction.execute() returns "get"  (in hopes of chaining GetAction)
>
> However, after SaveAction.execute(), I get an exception stating that the
> result "get" is not found.
> "No result defined for action com.company.web.actions.SaveAction and result
> get"
>
> Note that, both of these guys are in the same package, and therefore in the
> same namespace.
> Through the config-browser, I did verify that "get" is not one of the listed
> result types not found.
>
> Ed
>
>
>
> On Tue, Mar 10, 2009 at 12:19 PM, Musachy Barroso <mu...@gmail.com> wrote:
>
>> The problem in your case, is that Convention tries to find
>> "get-get.jsp" and then tries "get.jsp", which it will find, so it will
>> never chain to the action, but rather dispatch to the jsp. Chaining
>> only works when no result is found.
>>
>> musahcy
>>
>> On Tue, Mar 10, 2009 at 12:12 PM, Musachy Barroso <mu...@gmail.com>
>> wrote:
>> > Yes, you can chain actions if they are in the same package:
>> >
>> >
>> http://cwiki.apache.org/WW/convention-plugin.html#ConventionPlugin-Chaining
>> >
>> > musachy
>> >
>> > On Tue, Mar 10, 2009 at 11:52 AM, Edward Song
>> > <ed...@nuhorizons.com> wrote:
>> >> Hi all,
>> >>
>> >> This question concerns the Convention Plugin, specifically in regards to
>> >> Action Chaining.
>> >>
>> >> I am using Struts 2.1.6
>> >>
>> >> I have the following package structure.
>> >>
>> >>  com.company.web.actions.administrators.GetAction
>> >> (/administrators/get)
>> >>  com.company.web.actions.administrators.SaveAction
>> >> (/administrators/save)
>> >>
>> >> After SaveAction.execute(), I wanted to use action chaining and forward
>> >> to GetAction.execute().
>> >>
>> >> I was able to get this to work via annotations in my SaveAction class.
>>  The
>> >> execute() method returns ActionSupport.SUCCESS.
>> >>
>> >> @Results({
>> >>
>> >> @Result(name=ActionSupport.*SUCCESS*, type="chain", location="get")
>> >>
>> >> })
>> >> However, it seems through the examples, that annotations may not be
>> required
>> >> for simple action chaining.
>> >> Can we return an action name, effectively chainining the actions
>> together?
>> >> I had attempted returning "get" in my SaveAction.execute(), thinking
>> that it
>> >> would action chain GetAction.
>> >> The result was forwarded to my /WEB-INF/content/administrators/get.jsp,
>> but
>> >> never actually ran GetAction.execute() .
>> >>
>> >> Any idea as to what my SaveAction.execute() method should return to
>> >> accomplish simple action chaining without the annotation above?
>> >>
>> >> Thank you in advance.
>> >>
>> >
>> >
>> >
>> > --
>> > "Hey you! Would you help me to carry the stone?" Pink Floyd
>> >
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Convention Plugin and Action Chaining

Posted by Edward Song <ed...@nuhorizons.com>.
Thanks Musachy for your prompt response.

Makes total sense.

However, I now tried the following based on your reply....

GetAction.execute() returns ActionSupport.SUCCESS.
forwards to....
get-success.jsp  (renamed get.jsp, so that it would not be found in the
instance below)

SaveAction.execute() returns "get"  (in hopes of chaining GetAction)

However, after SaveAction.execute(), I get an exception stating that the
result "get" is not found.
"No result defined for action com.company.web.actions.SaveAction and result
get"

Note that, both of these guys are in the same package, and therefore in the
same namespace.
Through the config-browser, I did verify that "get" is not one of the listed
result types not found.

Ed



On Tue, Mar 10, 2009 at 12:19 PM, Musachy Barroso <mu...@gmail.com> wrote:

> The problem in your case, is that Convention tries to find
> "get-get.jsp" and then tries "get.jsp", which it will find, so it will
> never chain to the action, but rather dispatch to the jsp. Chaining
> only works when no result is found.
>
> musahcy
>
> On Tue, Mar 10, 2009 at 12:12 PM, Musachy Barroso <mu...@gmail.com>
> wrote:
> > Yes, you can chain actions if they are in the same package:
> >
> >
> http://cwiki.apache.org/WW/convention-plugin.html#ConventionPlugin-Chaining
> >
> > musachy
> >
> > On Tue, Mar 10, 2009 at 11:52 AM, Edward Song
> > <ed...@nuhorizons.com> wrote:
> >> Hi all,
> >>
> >> This question concerns the Convention Plugin, specifically in regards to
> >> Action Chaining.
> >>
> >> I am using Struts 2.1.6
> >>
> >> I have the following package structure.
> >>
> >>  com.company.web.actions.administrators.GetAction
> >> (/administrators/get)
> >>  com.company.web.actions.administrators.SaveAction
> >> (/administrators/save)
> >>
> >> After SaveAction.execute(), I wanted to use action chaining and forward
> >> to GetAction.execute().
> >>
> >> I was able to get this to work via annotations in my SaveAction class.
>  The
> >> execute() method returns ActionSupport.SUCCESS.
> >>
> >> @Results({
> >>
> >> @Result(name=ActionSupport.*SUCCESS*, type="chain", location="get")
> >>
> >> })
> >> However, it seems through the examples, that annotations may not be
> required
> >> for simple action chaining.
> >> Can we return an action name, effectively chainining the actions
> together?
> >> I had attempted returning "get" in my SaveAction.execute(), thinking
> that it
> >> would action chain GetAction.
> >> The result was forwarded to my /WEB-INF/content/administrators/get.jsp,
> but
> >> never actually ran GetAction.execute() .
> >>
> >> Any idea as to what my SaveAction.execute() method should return to
> >> accomplish simple action chaining without the annotation above?
> >>
> >> Thank you in advance.
> >>
> >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Convention Plugin and Action Chaining

Posted by Musachy Barroso <mu...@gmail.com>.
The problem in your case, is that Convention tries to find
"get-get.jsp" and then tries "get.jsp", which it will find, so it will
never chain to the action, but rather dispatch to the jsp. Chaining
only works when no result is found.

musahcy

On Tue, Mar 10, 2009 at 12:12 PM, Musachy Barroso <mu...@gmail.com> wrote:
> Yes, you can chain actions if they are in the same package:
>
> http://cwiki.apache.org/WW/convention-plugin.html#ConventionPlugin-Chaining
>
> musachy
>
> On Tue, Mar 10, 2009 at 11:52 AM, Edward Song
> <ed...@nuhorizons.com> wrote:
>> Hi all,
>>
>> This question concerns the Convention Plugin, specifically in regards to
>> Action Chaining.
>>
>> I am using Struts 2.1.6
>>
>> I have the following package structure.
>>
>>  com.company.web.actions.administrators.GetAction
>> (/administrators/get)
>>  com.company.web.actions.administrators.SaveAction
>> (/administrators/save)
>>
>> After SaveAction.execute(), I wanted to use action chaining and forward
>> to GetAction.execute().
>>
>> I was able to get this to work via annotations in my SaveAction class.  The
>> execute() method returns ActionSupport.SUCCESS.
>>
>> @Results({
>>
>> @Result(name=ActionSupport.*SUCCESS*, type="chain", location="get")
>>
>> })
>> However, it seems through the examples, that annotations may not be required
>> for simple action chaining.
>> Can we return an action name, effectively chainining the actions together?
>> I had attempted returning "get" in my SaveAction.execute(), thinking that it
>> would action chain GetAction.
>> The result was forwarded to my /WEB-INF/content/administrators/get.jsp, but
>> never actually ran GetAction.execute() .
>>
>> Any idea as to what my SaveAction.execute() method should return to
>> accomplish simple action chaining without the annotation above?
>>
>> Thank you in advance.
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Convention Plugin and Action Chaining

Posted by Musachy Barroso <mu...@gmail.com>.
Yes, you can chain actions if they are in the same package:

http://cwiki.apache.org/WW/convention-plugin.html#ConventionPlugin-Chaining

musachy

On Tue, Mar 10, 2009 at 11:52 AM, Edward Song
<ed...@nuhorizons.com> wrote:
> Hi all,
>
> This question concerns the Convention Plugin, specifically in regards to
> Action Chaining.
>
> I am using Struts 2.1.6
>
> I have the following package structure.
>
>  com.company.web.actions.administrators.GetAction
> (/administrators/get)
>  com.company.web.actions.administrators.SaveAction
> (/administrators/save)
>
> After SaveAction.execute(), I wanted to use action chaining and forward
> to GetAction.execute().
>
> I was able to get this to work via annotations in my SaveAction class.  The
> execute() method returns ActionSupport.SUCCESS.
>
> @Results({
>
> @Result(name=ActionSupport.*SUCCESS*, type="chain", location="get")
>
> })
> However, it seems through the examples, that annotations may not be required
> for simple action chaining.
> Can we return an action name, effectively chainining the actions together?
> I had attempted returning "get" in my SaveAction.execute(), thinking that it
> would action chain GetAction.
> The result was forwarded to my /WEB-INF/content/administrators/get.jsp, but
> never actually ran GetAction.execute() .
>
> Any idea as to what my SaveAction.execute() method should return to
> accomplish simple action chaining without the annotation above?
>
> Thank you in advance.
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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