Hi, I want to use two Actionforms into a action class? Can I use it? Currently I am using it but it is giving me error like :- =========================================== 11:15:10,984 ERROR [[action]] Servlet.service() for servlet action threw exception java.lang.ClassCastException: com.econify.struts.form.ViewcartForm at com.econify.struts.action.UpdatecartAction.featureditemform(UpdatecartAction.java:97) at com.econify.struts.action.UpdatecartAction.execute(UpdatecartAction.java:86) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) ===========================================
What should I do if I want to use two forms inside same action class? Please help me. Thanx in advance. Prash
********Deserve Before You Desire********
Joined: May 05, 2006
I think you should wrap the 2 forms you want into one form and use that form. I don't think you can define more than one form for one action.
Joined: Feb 15, 2005
You can only define one ActionForm per action mapping, but more than one action mapping can point to the same Action class.
The answer to your question is yes, it is possible to have the same Action class use more than one ActionForm. Here's an example:
The execute() method of an Action class receives an object of type ActionForm as a parameter. It is up to you to cast this object to the correct subclass of ActionForm. The execute() method also receives an object of type ActionMapping as a parameter. You could therefore do something like this: