?
Solved

How to use two action forms inside same action class?

Posted on 2006-07-13
3
Medium Priority
?
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
anumalas earned 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 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