why do we typecast ActionForm into our plain java bean
class in Action class? What is the reason?

Answer Posted / supra

Use ActionForm to work on session data

In a Struts-based Web application, each ActionForm extends
org.apache.struts.action.ActionForm. These ActionForms
encapsulate page data and provide a validation framework to
validate request parameters.

Most Web applications maintain data in session to make them
available throughout the application. This best practice
addresses this Web application feature. It allows methods
toSession() and fromSession() to move session data to and
from the form data. Thus, it addresses session data
maintenance in a Web application.

To adhere to this practice, follow these steps:

Create an abstract class named BP3Form by extending
org.apache.struts.action.ActionForm.
In BP3Form, add methods with access modifiers as in public
abstract void toSession(SessionData sessionData) and void
fromSession(SessionData sessionData).
In every ActionForm, extend BP3Form and implement the
abstract methods in which the form data is transported to
and from the session.
The corresponding Action class may determine the order in
which these methods are called. For example, you could
invoke method toSession() on the ActionForm just before
actionForward is determined.
When to use this practice

This practice is most useful when session data is
maintained as a single object and/or every page manipulates
or uses session data.

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of struts.properties in struct2?

531


What is struts.devmode?

577


What types of validations are available in xml based validation in struts2?

555


Which interceptor is responsible for file upload support?

581


1.can we transfer a request from one struts application to another struts application? 2. how many types of action servlets r there what r they

2759






What does it cost to replace struts?

506


What is the purpose of global-forwards tag in struct-config.xml?

584


How many Action classes have been used in your project? Differences between struts 1.1 and 1.3?

2536


how to connect from struts to database through hibernet and where u can modify the class

2119


What are the advantages of spring mvc over struts mvc?

501


What is struts2 in java?

536


Why do the struts tags provide for so little formatting?

588


What is the purpose of @result?

585


In which method of action class the business logic is executed?

546


how to develop the submit and search operations in single jsp using struts?

2560