64. What is Action Class

  • The Action is part of the controller. The purpose of Action Class is to translate the HttpServletRequest to the business logic.
  • To use the Action, we need to  Subclass and overwrite the execute()  method.
  • The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method.
  • There should be no database interactions in the action.
  • The action should receive the request, call business objects (which then handle database, or interface with J2EE, etc) and then determine where to go next.
  • Even better, the business objects could be handed to the action at runtime (IoC style) thus removing any dependencies on the model.  
  • The return type of the execute method is ActionForward which is used by the Struts
  • Framework to forward the request to the file as per the value of the returned ActionForward object.
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.