File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Meteor in Action
this week in the
Two actions in single button click
Joined: Jun 04, 2005
Feb 04, 2012 01:40:18
My requirement is when user clicks submit button two business should execute, that is two actions should perform in single button click.
script i executed the below code when the user clicks the submit button.
document.forms.action =”servlet1.do?method=[b]validate[/b]”; document.forms.sumbit(); document.forms.action =”servlet1.do?method=[b]PDFOpen[/b]”; document.forms.sumbit();
In the validate method, list of values should validate in external system and display the message as Amount is validated in the screen.
In the PDFOpen method open the
document in separate window based on validation of data(dynamic data )
Here the problem before the validate method complete PDFOpen method s executing, so that PDF document is opening before the validation. Could you please suggest how to design for the requirement.
Thanks in Advance.
Author and ninkuma
Joined: Jan 10, 2002
Feb 04, 2012 10:06:52
Once you submit the form, control passes to the
and the page is unloaded, so you can't submit the form again as the code after the submission will never execute.
If you want to make multiple submissions from the page
unloading that page, you'll need to use Ajax.
Asking smart questions
Books by Bear
Joined: Jan 21, 2012
Feb 06, 2012 05:03:50
Why not handle all these two actions in Servlet on click of Button ? Ajax too could give you same problem (PDF document is opening before the validation) , might be synchronizing Ajax call can help you.
Joined: Nov 08, 2001
Feb 06, 2012 08:55:14
OR submit the page to one place and have the server make the second call.
I agree. Here's the link:
subject: Two actions in single button click
Struts parent & popup window with validator framework
intermediate submit and validation of a form
Bypassing form validation
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015