Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Do I Handle Two Action Forms?

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • 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.
 
Rick Hightower
Author
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post a code snippet of the JSP with the two forms.
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic