Expose xforms-submit event data to javascript (Orbeon 4.0 CE)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Expose xforms-submit event data to javascript (Orbeon 4.0 CE)

Simon-2
Hello,

I'm trying to access the event('response-status-code') and event('response-body') data from the xforms-submit-error, and xforms-submit-done events.
This would allow me to be able to add contextual information via javascript to the user. For example, on error, our persistence layer will return a javascript object describing the nature of the failure, for example conflicting Id, schema validation failure, etc...

but I just end up with `undefined` values from my calls to ORBEON.xforms.Document.getValue(formOutputId)

I have tried numerous variations of this:

<!-- An instance to hold the response error data -->
<xforms:instance id="submit-error">
    <error>
         <response/>
         <responseCode/>
    </error>
</xforms:instance>

<!-- React to failed submission -->
<xf:action ev:event="xforms-submit-error"
               ev:target="fr-create-update-submission fr-create-update-attachment-submission fr-get-document-submission fr-pdf-service-submission fr-email-service-submission">

    <!-- Add the response data to the submit-error instance -->
    <xf:var name="responseBody" select="event('response-body')"/>
    <xf:var name="responseCode" select="event('response-status-code')"/>
    <xf:setvalue ref="instance('submit-error')/response" value="$responseBody"/>
    <xf:setvalue ref="instance('submit-error')/responseCode" value="$responseCode"/>

    <!-- Do something with response error -->
    <xxf:script>
            var statusCode = ORBEON.xforms.Document.getValue("error-status-code"),
                responseBody = ORBEON.xforms.Document.getValue("error-response-body");
            alert('status:' + statusCode + "\nresponse:" + responseBody);
    </xxf:script>
</xf:action>


<xhtml:span  class="hidden">
    <xforms:output ref="instance('submit-error')/response" id="error-response-body"/>
</xhtml:span>  
<xhtml:span  class="hidden">
    <xforms:output ref="instance('submit-error')/responseCode" id="error-status-code"/>
</xhtml:span>  



Do I need to do something differently in Orbeon 4.x? Or can you see something I'm doing wrong?

Thank you for your help,

Simon Flack
Web Developer @ the BBC

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Expose xforms-submit event data to javascript (Orbeon 4.0 CE)

Alessandro  Vernet
Administrator
Hi Simon,

Something along these lines should still work. Could you share with us exactly where you put that code, so we know how to reproduce the problem?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet