• 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

How Do I Handle Two Action Forms?

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am stuck and need your knowledge and experience.
When the button is my JSP is clicked, there are two action forms involved, threadForm and postForm.
The threadForm is populated by hidden fields and text fields that are passed from the JSP. All the properties of the threadForm are to be inserted into a table in the database by the threadInsert() method and this method returns a primitive int threadID.
The properties in the postForm are also populated by hidden fields and text fields that are passed from the same JSP, except that the postForm has one additional properties - threadID, which is obtained from the insertion of the threadForm into the database. Thereafter, all the properties of the postForm are to be inserted into another table in the database by the postInsert() method.
How do I handle this situation? Please help.
 
Author
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post a code snippet of the JSP with the two forms.
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand what you are trying to accomplish, but not sure on what the problem is?
I don't necessarily need code, but are you using DispathAction? If not, just a standard action servlet? Are you using DynaForms or form classes?
Typically in the scenario you descibe, you have a single form and the ID is null or blank in your first process, then, when passed back to the same JSP, the ID now has a value and is posted during the second process you describe.
Your action method would need to check the value of ID to see if you need to perform the first or second action, based on whether the ID is null or not.
I personally would recommend using DispatchAction instead and based on which option is clicked, call the appropriate method, rather than have a single method doing both processes.
 
There is no "i" in denial. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic