aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
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
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

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?