• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Issue with multiple form beans

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All ,

I have a JSP page in which there are 2 html forms each associated with a particular form bean .
Once I submit the page i need to get both the form beans in my action class.
can anyone give some pointers

Thanks
Shiva
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Struts, the action parameter of an <html:form> tag is an action defined in the struts-config.xml file. Each action is associated with a particular form.

Even though there are two forms on a page, they are each submitted separately unless you create javaScript that will submit them together. There is a one-to-one relationship between an action and a form bean. So, the short answer to your question is no, you can't read two form beans at the same time on a submit.

However, there's no reason you can't have two struts actions that both use the same action class. In this case, the action class can decide which form bean to cast it's ActionForm input parameter to.

For example, let's suppose your action class is a subclass of DispatchAction, which means that it will forward to different methods named for the contents of a specified input field, such as "edit" or "delete". In this case, both the edit() and delete() methods can cast to different suclasses of ActionForm.
 
shiva viswanathan
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Merill ,

Is there any way to submit 2 forms at once in javascript .
If so , how can i obtain both in my action form .

One of the assumptions I am making is that when a form is submitted the corresponding form bean gets set into session. I have already tried this and it works.

So are you saying that the solution to my problem is more associated with javascript rather than struts .

Also in such a case do i create the 2 forms using html:form or ordinary form tag in html

Thanks
Shiva
 
Sunglasses. AKA Coolness prosthetic. This tiny ad doesn't need shades:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic