We can write our own Action class using Struts framework but need to extends Action class of org.apache.struts.action package and need to override execute() method which return the ActionForward class object and which must be return by calling the findForward() method with ActionMapping reference and hence control will transfer to the caller i.e RequestProcessor.

Description about execute()

public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, 
 HttpServletResponse response)throws Exception { 

    return mapping.findForward(result);

}

Caller of the execute() is RequestProcessor and return will also go the RequestProcessor. So by this we can confirm that after calling process() method by the RequestProcessor , now its the responsibility of the RespectProcessor to handle all the request of the client by calling execute() method.

execute() method is parametrized with ActionMapping , ActionForm , HttpServletRequest, HttpServletResponse reference.

Why ActionMapping ?

It is because findForward() method is implemented in the  ActionMapping class only and return ActionForward object.

Why ActionForm ?

It is because because before control comes to Action class it check the form bean class and hence its object has all the required value of the HTML form elements ( text field, checkboxes, drop down etc ).

Why HttpServletRequest ?

It is because to handle and process the request by the clients.

Why HttpServletResponse ?

It is because to send the response to the client after processing the request.

Note: Each Action class must be mapped in the struts-config file within action-mapping tag and hence need to also configure its from bean class.



0 comments:

Post a Comment

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic