Solved

How to use two action forms inside same action class?

Posted on 2006-07-13
3
287 Views
Last Modified: 2009-12-16
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
0
Comment
Question by:Econify
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
anumalas earned 500 total points
ID: 17106195
Hi

Using DispatchAction and LookupDispathAction you can have two forms for one action.

As per best practices each action can have only one form. in execute() method we will pass the actionform instance as a parameter.

There is one alternate way to hold form data

public class YourActionForm()
{

private SomeOtherFormDataBean someExtra; //This is the bean contains some properties, getter and setters;

public void setSomeExtra(){} // setter of your bean
public SomeOtherFormDataBean getSomeExtra(){} // getter of your bean
}

write bean

in action class execute method

form.getSomeOtherDataBean.setSomeProperty() // to set data values;

like above you can use multiple beans in a single form to store/retrive different set of properties instead of using muiltiple forms

Hope this will help :)
0
 

Author Comment

by:Econify
ID: 17119949
Hi anumalas .
thanx for ur help. I found some other way for doing above thing. I think that is easier for me.
The other solution is :- uisng two actions pointing to same action class.
I assume your solution will also work for me.
So anyways I give up all points to you.
Thanx again.
0
 
LVL 3

Expert Comment

by:anumalas
ID: 17119961
Hi Econify

good go ahead. :)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Run jasper report from servlet 1 206
issue with pdf generation 2 78
oracle fusion vs MQ 2 93
spring example non maven 4 75
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now