This blog post intends to answer the following questions : -
Basically Struts 2 allows you to create Action classes in three different ways :-
public String execute()
{
//method code
}
Happy Programming ;)
Signing Off
Ryan
- How to create Action classes in Struts 2?
- Can we use POJO's as action classes in Struts 2?
- How to use a POJO as an action class in Struts 2?
- What are the interfaces or classes one needs to extend to create an action class in Struts 2?
The Struts 2 programming model makes it very easy to create action classes. The Dependency Injection pattern enables us to add Struts 2 functionality to a variety of classes.
Basically Struts 2 allows you to create Action classes in three different ways :-
- Implement the org.apache.struts.action.Action interface.
- Extend the com.opensymphony.xwork2.ActionSupport class.
- Or simply use any POJO as an Action class.
Implementing the Action interface is very useful in cases when your class belongs to some other class hierarchy. Extending the ActionSupport class enables us to to make use of a large number of features and constants that are available through the various interfaces implemented by the ActionSupport class. ActionSupport provides empty implementations of a large number of abstract methods for many interfaces.
Using a POJO is quite simple as well. All that is required of you is to create method in the POJO with the following signature : -
public String execute()
{
//method code
}
So finally, getting down to the actual business details is not gonna take millions of years! Have fun!
Happy Programming ;)
Signing Off
Ryan
No comments:
Post a Comment