my dog learned polymorphism*
The moose likes Struts and the fly likes Problem with ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with ActionForm" Watch "Problem with ActionForm" New topic

Problem with ActionForm

Pramod Kumar
Ranch Hand

Joined: Oct 05, 2007
Posts: 40
I have a form bean class in a jar file and it is not extending ActionForm, Now I need to use that bean and need to write Action class to that. In struts-config.xml I have configured that bean and in Action class I wrote

User user = (User)form; and in eclipse it is showing error Cannot cast from ActionForm to User.

How can I solve this problem.
Chris Boldon
Ranch Hand

Joined: Aug 10, 2006
Posts: 190
You can't cast from an ActionForm to a bean or vo. You have to map the variables manually. Create a mapFormToXXXX method.
It is sorta covered in the JavaRanch Style Guide.
subject: Problem with ActionForm
Similar Threads
How to send data from Action to Bean, to create a record in the database in struts 1.3
Issue in Struts Dropdown(Need Help Ranchers)
Exception creating bean of class com.user
Collections of Objects within an ActionForm
Validation+struts frame work