Search code examples
javaxpagese-commercecxml

xPages HowTo handle incoming FORM POST punchOutOrderMessage (POOM)


I'm setting up the Byer-Side of a PunchOut solution.

https://punchoutcommerce.com/guides/punchout/cxml-punchout-setup-request/

Everything works fine until the actual "Cart-PunchOut". (Creating a PunchOutReguest, redirecting to the sellers webshop, doing some shopping, works fine) In my PORequest there's an URL to which the user will be redirected when clicking "PunchOut Cart" According the implementation the seller is doing a FORM POST with an cXML file in a hidden input field like this: https://punchoutcommerce.com/guides/punchout/cxml-punchout-order-message/#cart_transmission.

On my postBack xPage I have tried some different solutions to get a handle of the FORM POST HTML and handle it in my java Bean. But nothing seems to work!

Can anyone point me in the right direction on how to handle an incoming HTML FORM POST on my xPage?

My problem is NOT how to decode the cxml-base64 string in my bean, my problem is how to get hold of the Form Data at all in my xPage and populate/create an instance of my JavaBean, preferably via ServerSideJavaScript.

After some more digging to ensure that I actually get something in return I clearly see this in chrome DevTools Network Inspector: Screenshot from Chrome DevTools


Solution

  • You should be able to get hold of the form fields using the getRequestParameterValuesMap() method on ExternalContext.

    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    Map<String, String[]> inputFieldMap = ec.getRequestParameterValuesMap();
    

    I use that in an application where the form fields come from a form not generated by XPages itself.

    If you want to get hold of the form fields using SSJS, then have a look at this answer.