This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes why do we typecast ActionForm into our plain java bean class in Action class? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "why do we typecast ActionForm into our plain java bean class in Action class? " Watch "why do we typecast ActionForm into our plain java bean class in Action class? " New topic
Author

why do we typecast ActionForm into our plain java bean class in Action class?

p hasini
Ranch Hand

Joined: Oct 24, 2009
Posts: 92
why do we typecast ActionForm into our plain java bean class in Action class? What is the reason.
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Take a look at the API doc of ActionForm class.
Now I typical subclass of ActionForm that we create would look something like this

Now in your action class, if you don't cast ActionForm to LogicForm, then you won't be able to call getUsername or getPassword methods. So basically you can access only the methods of ActionForm class. So then what's the use of ActionForm if you can't access the properties that you created in the bean associated with your Action?? You won't be able to leverage the automatic request parameter transferring capability of Struts as you'll have to access request parameters from the HttpServletRequest object...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why do we typecast ActionForm into our plain java bean class in Action class?
 
Similar Threads
Display the contents of folder when the link is clicked
ActionForm
can't typecasting in struts??
Struts 1 Would ActionForm be Null
Why do we need ActionForm ?