| Author |
Handoff From Action-1 to Action-2
|
Bob Harrison
Greenhorn
Joined: Apr 18, 2006
Posts: 12
|
|
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
|
"In theory there is no difference between theory and practice. In practice there is."<br />Yogi Berra
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
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");
|
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
|
 |
Bob Harrison
Greenhorn
Joined: Apr 18, 2006
Posts: 12
|
|
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
|
 |
Brent Sterling
Ranch Hand
Joined: Feb 08, 2006
Posts: 948
|
|
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
Joined: Apr 18, 2006
Posts: 12
|
|
All very good suggestions. I'll let y'all know how this turns out. Thanks, Bob
|
 |
 |
|
|
subject: Handoff From Action-1 to Action-2
|
|
|