Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to submit two forms on same page?

 
Greenhorn
Posts: 4
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
0 down vote favorite
share [fb] share [tw]


Case:

I have two forms
1> Own Customized Form say form1.
2> Form rendering from third party java script call say form2.

Previously there was only one form
(no third party form) with same fields.
Thus I was submitting it using single submit button.
Lets say I was calling Action1 for my old form.

The third party form has own submit button and it post values (Not all. Only Third Party
values ) to own controller and returns response .

I don't want to ask user to submit twice on same page.

I want to submit both forms on old submit button and hide third party submit button.

I can change the response URL (where to land to get third party form submit response ).

I am thinking to hide third party submit button with css and call click/submit that when I
click old submit button using javascript.

Lets set response landing page for third party to Action1.

But if I land on old action ie Action1 I cant able to get old customized form element?

I am stuck in this scenario.

Can you have any better solution to this?

[Using struts framework and jsp for rendering form.]
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may not submit two forms, but you can chose to submit how many fields you want to submit. After all that is what you would be wanting to do - submit data.
 
Ranch Hand
Posts: 77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way you can do it is using JavaScript and ajax, you can grab all the values of the two forms and build up a single ajax request. ajax requests would work similar to a form submit.. should be easy enough to handle it for one request with one action class. You may need to figure out the 3rd party component fields and modify them in your JS so as to properly auto-populate your own custom bean that the action class can then use.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic