Announcement Announcement Module
No announcement yet.
Form POST from controller with external URL Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Form POST from controller with external URL


    I have a problem I cannot seem to find a way to address.

    I have a form (shopping cart) that has 2 buttons. One button recalculates the cart value if item quantities are changed. The other button is to Proceed to checkout.

    I have a controller that the form action posts to and if it is a recalculate the cart is updated and the cart is redisplayed (easy).
    If the proceed to checkout is pressed I need to construct a POST (or forward the POST) to the PayPal URL with the cart contents. All the cart contents are in hidden fields and already to be passed directly to PayPal. If this was the only button on the form the action for the POST would be the correct PayPal URL and I would set the target on the form to another window such as PayPal so a new window for the PayPal payment can be completed.

    How do I do this. i.e. after a POST is directed to a controller, have that controller send another POST automatically with a different action and with the request parameters from the previous form. Included in this action would be to create the new target for the PayPal payment process???

    Any help here or a strategy to handle it would be great....



  • #2
    Any body got any ideas?

    I realise this maybe a difficult topic but I could realy do with being pointed in the right direction even if that means changing my approach somewhat.

    Any help here would be very welcome.



    • #3
      Recalculating the cart value in the way you describe sounds like a perfect job for AJAX -

      No need for form redirects then.



      • #4
        Once again I am looking for some direction.

        The AJAX suggestion does not do what I need to do. How can I handle this in Spring?

        A Two button form with a single action.

        The handler detemins the button pressed (by name or property)

        Button 1 recalculates the cart value and redisplays the cart. (Works fine)
        Button 2 needs to create a new window target (for PayPal payment) and then force a POST directed at that target window.... The cart form and its table creates all the required hidden field information for PayPal integration.

        I was thinking something along the lines of:

        1. Create a new ModelAndView to a blank view. (not sure how to force a new window though)
        2. The new blank view handler uses Apache HTTPClient to create a new POST from the original form elements.
        3. The handler returns null as the ModelAndView to state it has already been handled.
        4. The PayPal responce is rendered to the view.

        Maybe step 1 and the first part of step 2 can be left out as the response from PayPal will render to the current browser window but I still would like the PayPal activity to occure in a new target window and not in my shoppingcart window..