• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Two actions in single button click

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My requirement is when user clicks submit button two business should execute, that is two actions should perform in single button click.

In java script i executed the below code when the user clicks the submit button.



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 PDF 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.

 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once you submit the form, control passes to the servlet 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 without unloading that page, you'll need to use Ajax.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OR submit the page to one place and have the server make the second call.

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic