• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handoff From Action-1 to Action-2

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am posting a transaction to a vendor (Action-1). After posting, Action-1 returns null. If Action-1 posting is successful, the vendor posts back a transaction number to a second action (Action-2). I want Action-2 to confirm the successful transaction and forward the user to a "home page".

I can confirm that Action-1 successfully POSTs to the vendor, that the vendor's POST back contains the transaction number and that Action-2 can read it i.e. the "xid" parameter in action-2 is not null.

However, instead of being forwarded to the "home page" from Action-2, execution comes back to action-1 at the "return null;" line and I get a blank screen.

Here's struts config for the two actions:




Here's the code snippet for action-1:


And, here's the code snippet for Action-2


I would appreciate help in how to pass from Action-1 to Action-2 or a better way to perform this task.

Thanks,
Bob Harrison
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add one more <forward ..> in action-1 mapping to action-2 like below,

<action-1
path="/makePayment"
input="/creditCardPayment.jsp" name="CreditCardForm"
scope="request" type="com.beeslender.struts.CreditCardPaymentAction">
<forward name="success" path="/<action-2 Path>.do"/> // mapping to action-2
<forward name="payment.failure" path="/makePaymentPage.do" /> // try again
<forward name="payment.cancel" path="/landingPage.do"/> // to the index page
</action>




And instead of returning null from action-1, return mapping.findForward("success");
 
Bob Harrison
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prabhu,
Thanks for the suggestion. When I do that, Action-2 gets hit twice - the second time, xid is null and I'm kicked back to the previous screen.

I think that makes sense. Action-2 is being called by Action-1 and by the vendor's post-back.

Any other ideas?

Bob
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems to me that in Action-1 you will need to send the post to the external vendor and then some how wait for the response. My first though would be to set up a loop that polled the database (or some other external resource) looking for a status. When Action-2 is called it would update the database record with the success status. A similar option (and something that is common for long running queries) would be to have Action-1 forward to a "your request is processing" page and have that page refresh every few seconds and check the processing status. If processing is complete then forward to the "success" page.

Is there anyway to have the vendor return the status on your request or for you to switch over to more of a web services interface?

- Brent
 
Bob Harrison
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All very good suggestions. I'll let y'all know how this turns out.

Thanks,

Bob
 
reply
    Bookmark Topic Watch Topic
  • New Topic