wood burning stoves 2.0*
The moose likes Struts and the fly likes struts2 Action class implementation question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 Action class implementation question." Watch "struts2 Action class implementation question." New topic
Author

struts2 Action class implementation question.

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Can my Action class return Result Objects such as success , error ,login ---etc and override the execute Method ??
If i don't extend the ActionSuppourt or implement the Action interface ??


Is this still possible??

If you want something you never had do something which you had never done
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688


Hi,

IN struts 2 it is not compulsory to implement your action class to ActionSupport interface.


If you don't want to implement your action class to ActionSupport interface then you must override execute() method. Then you get your class same work as your Action class.



Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Hi,

Thanks for the answer .

So is it possible to override the execute() even if i dont' implement the Action interface and extend ActionSuppourt class??
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688


Yes you can.

just make simple java class and override execute() method. That class also you can use Struts 2 Action class.

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 688


For better Ref : -http://www.theserverside.com/tt/articles/article.tss?l=SmartURLs

See the above link for better reference.

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Nishan Patel wrote:
Yes you can.

just make simple java class and override execute() method. That class also you can use Struts 2 Action class.




Thanks man
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just as a technical nitpick, it's not really "overriding" execute() if you're not extending a class that implements its own execute(), you're just implementing an execute() method.

Note that *not* extending ActionSupport (or implementing the interfaces it defines) removes a fair amount of functionality, notably all localization (including in the S2 tags in JSP pages) and validation.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
David Newton wrote:Just as a technical nitpick, it's not really "overriding" execute() if you're not extending a class that implements its own execute(), you're just implementing an execute() method.



Great point i could have understood this property after reading a ton of documents.
Thanks .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts2 Action class implementation question.