You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by phillips1021 <bp...@ku.edu> on 2009/08/31 22:13:56 UTC

Convention Plugin and Method Called In Action Class

I'm learning to use the Convention Plugin.

I understand from the excellent notes posted on the Wiki
(http://cwiki.apache.org/WW/convention-plugin.html) that the plugin finds
the Action classes and maps those action classes to Action names and results
to specific JSPs.  For example:

Action Class                 ->          Action URL   ->   View 
com.example.actions.MainAction -> /main -> /WEB-INF/content/main-success.jsp

What I'm not clear on is what method is called in the Action Class.  Is it
always the execute method?  Is there a way in the Action URL to specify
which method to call?

I know that I could use Struts 2 @Action annotation to map a method to an
Action URL, but I'm wondering if there is a way to call a specific method in
the Action class using just the Convention plugin and no annotations.

Thanks for the help.

Bruce

-- 
View this message in context: http://www.nabble.com/Convention-Plugin-and-Method-Called-In-Action-Class-tp25229678p25229678.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Convention Plugin and Method Called In Action Class

Posted by Paweł Wielgus <po...@gmail.com>.
Hi all,
in my apps i use only convention to manage action configuration,
and also i make use of addresses like:
myapp/myaction!input
they work for 2.1.6.
I don't know if convention has anything to do with it,
but to be sure You can use config browser plugin to see how things are mapped.

Best greetings,
Paweł Wielgus.


2009/8/31 phillips1021 <bp...@ku.edu>:
>
> I thought that was the case.  One of the references I'm using for the
> Convention plugin is the MEAP draft of Struts 2 in Practice (was sorry to
> learn that the book isn't being finished, the first few chapters were
> excellent).
>
> Using the bang (!) operator doesn't work with the Convention plugin.
>
> Oh well onto learning the Struts 2 annotations.
>
> Thanks for the information.
>
> __________________________________________
> It is going to default to the 'public String execute()' method. It
> might be possible to use the exclamation point to try to get the
> plugin to call a specific method ->
>
> http://localhost:8080/app/action!differentMethod
>
> Really though, this goes against the notion of 'conventions over
> configuration.' The @Action annotation would be a much more
> maintainable way to handle this sort of thing.
>
> -Wes
>
> --
> Wes Wannemacher
>
> Head Engineer, WanTii, Inc.
> Need Training? Struts, Spring, Maven, Tomcat...
> Ask me for a quote!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> --
> View this message in context: http://www.nabble.com/Convention-Plugin-and-Method-Called-In-Action-Class-tp25229678p25230919.html
> Sent from the Struts - User mailing list archive at Nabble.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: Convention Plugin and Method Called In Action Class

Posted by phillips1021 <bp...@ku.edu>.
I thought that was the case.  One of the references I'm using for the
Convention plugin is the MEAP draft of Struts 2 in Practice (was sorry to
learn that the book isn't being finished, the first few chapters were
excellent).

Using the bang (!) operator doesn't work with the Convention plugin.

Oh well onto learning the Struts 2 annotations.

Thanks for the information.

__________________________________________
It is going to default to the 'public String execute()' method. It
might be possible to use the exclamation point to try to get the
plugin to call a specific method ->

http://localhost:8080/app/action!differentMethod

Really though, this goes against the notion of 'conventions over
configuration.' The @Action annotation would be a much more
maintainable way to handle this sort of thing.

-Wes

-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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




-- 
View this message in context: http://www.nabble.com/Convention-Plugin-and-Method-Called-In-Action-Class-tp25229678p25230919.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Convention Plugin and Method Called In Action Class

Posted by Wes Wannemacher <we...@wantii.com>.
On Mon, Aug 31, 2009 at 4:27 PM, Java Struts<st...@gmail.com> wrote:
> Hi,
>
> could you please tell me how to post my question to this list?
>

You just did... The next one will cost you $1 (just kidding), but for
your next question, you'd be better off sending a separate email (not
a reply to an existing message) so people won't consider your message
to be thread-jacking.


>>
>> I'm learning to use the Convention Plugin.
>>
>> I understand from the excellent notes posted on the Wiki
>> (http://cwiki.apache.org/WW/convention-plugin.html) that the plugin finds
>> the Action classes and maps those action classes to Action names and
>> results
>> to specific JSPs.  For example:
>>
>> Action Class                 ->          Action URL   ->   View
>> com.example.actions.MainAction -> /main ->
>> /WEB-INF/content/main-success.jsp
>>
>> What I'm not clear on is what method is called in the Action Class.  Is it
>> always the execute method?  Is there a way in the Action URL to specify
>> which method to call?
>>
>> I know that I could use Struts 2 @Action annotation to map a method to an
>> Action URL, but I'm wondering if there is a way to call a specific method
>> in
>> the Action class using just the Convention plugin and no annotations.
>>
>> Thanks for the help.
>>

It is going to default to the 'public String execute()' method. It
might be possible to use the exclamation point to try to get the
plugin to call a specific method ->

http://localhost:8080/app/action!differentMethod

Really though, this goes against the notion of 'conventions over
configuration.' The @Action annotation would be a much more
maintainable way to handle this sort of thing.

-Wes

-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


Re: Convention Plugin and Method Called In Action Class

Posted by Java Struts <st...@gmail.com>.
Hi,

could you please tell me how to post my question to this list?

Thanks,

On Mon, Aug 31, 2009 at 4:13 PM, phillips1021 <bp...@ku.edu> wrote:

>
> I'm learning to use the Convention Plugin.
>
> I understand from the excellent notes posted on the Wiki
> (http://cwiki.apache.org/WW/convention-plugin.html) that the plugin finds
> the Action classes and maps those action classes to Action names and
> results
> to specific JSPs.  For example:
>
> Action Class                 ->          Action URL   ->   View
> com.example.actions.MainAction -> /main ->
> /WEB-INF/content/main-success.jsp
>
> What I'm not clear on is what method is called in the Action Class.  Is it
> always the execute method?  Is there a way in the Action URL to specify
> which method to call?
>
> I know that I could use Struts 2 @Action annotation to map a method to an
> Action URL, but I'm wondering if there is a way to call a specific method
> in
> the Action class using just the Convention plugin and no annotations.
>
> Thanks for the help.
>
> Bruce
>
> --
> View this message in context:
> http://www.nabble.com/Convention-Plugin-and-Method-Called-In-Action-Class-tp25229678p25229678.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>