Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 are the applications of struts?

897


What is the purpose of @action annotation?

968


What is the purpose of @requiredstringvalidator annotation?

880


What is the difference between struts1 and struts2?

875


Can I have html form property without associated getter and setter formbean methods?

951


Does Struts2 action and interceptors are thread safe?

1011


What is Custom Type Converter in Struts2?

1049


What is struts 2 framework in java?

974


Is struts action class singleton?

937


What is the purpose of @stringlengthfieldvalidator annotation?

1043


What are the ways in which duplicate form submission can occur?

880


What are the classes used in struts?

1040


Can we have multiple struts config files in a single web app?

887


Why actionservlet is singleton in struts?

953


What are the main classes which are used in struts application?

921