wood burning stoves 2.0*
The moose likes Struts and the fly likes Getting an action method to run only after another action method completes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting an action method to run only after another action method completes" Watch "Getting an action method to run only after another action method completes" New topic
Author

Getting an action method to run only after another action method completes

Willy Wonka
Greenhorn

Joined: Aug 19, 2010
Posts: 1
I'm new to struts, can anyone advise how I could achieve the following functionality.

I have a requirement to add a new [Save and Print] button function to a JSP in my struts app. This functionality is required to save the current form and then launch a pdf for printing. Both these functions already exist separately and this requirement is designed to perform both operations in one click. The question I have is how can I get the 2 fumctions to run sequentially, i.e. finish save and then launch pdf. In my new saveAndPrint() js function I call the save() function and then return to launch a modal window in which a JasperReports pdf is produced.

The problem is the print method on the action class executes before the save has completed and therefore the model classes that store the data from the backing form do not reflect the changes to the form and I cannot re-extract the data as it has not yet been assigned an Id from the database.

I tried adding a setTimeout prior to calling the print action method however it never gets triggered, is this because the form has been submitted as part of the save?

Sriram Ture
Greenhorn

Joined: Aug 20, 2010
Posts: 23
Hi,

Dont do the check on client side, do it on server side.


Regards,
Sriram
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please see the JavaRanch naming policy and change your display name to conform with this policy. Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Getting an action method to run only after another action method completes