File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForm" Watch "ActionForm" New topic


Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
What is the role of ActionForm in Struts?What does the below statement mean?
Struts reuses ActionForms instead of creating new ones for each request

Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 445

Hi Philippe,

Struts uses ActionForms to transfer the request parameters from the client to the execute() in the Action class on the server. It abstracts the usage of the HttpRequest.getParameter() which had to be used to retrieve each individual parameter till the Struts came along. The request parameters could then be processed as appropriate.

The reuse part means that Struts does not create new instances of the Form bean mapped to a particular form. If one is available it is used after calling the reset() method the nest time the same form is submitted.

[ July 10, 2008: Message edited by: Raj Kamal ]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3381

Obviously the ActionForm is nothing but the carrier for the having the values set in the HTML form and which is what getting bound to the appropriate properties of the Form Bean you have. Instead of recreating new ActionForms, it is better reused!

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
I agree. Here's the link:
subject: ActionForm
It's not a secret anymore!