Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts2 Action class implementation question.

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.


 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

See the above link for better reference.

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic