xforms-submit-data-received

Mark Birbeck's picture

[This is a placeholder so that the discussion isn't lost.]

This event is dispatched when the XForms processor has correctly received some data.

event.error

The event.error flag will be set to true if there was an underlying protocol error, and this also signifies that an xforms-submit-error will be dispatched. (If there was a fatal error the xforms-submit-data-received event would not have been dispatched.)

The form author can clear the error flag if they want to prevent an xforms-submit-error from being dispatched at the end of processing, and as a result the data returned will be placed in the target instance as normal:

  <xf:action if="(number(event()/status) = 404">
    <xf:setvalue ref="event()/error" value="false()" />
  </xf:action>

They could also set the flag--so if a service returns HTTP 200 but there are no results, the author could set the error property and so force an xforms-submit-error at the end of processing.

event.response()

This provides access to the returned data:

  <xf:action if="number(event()/response()/@numresults) = 0>
    <xf:setvalue ref="event()/error" value="true()" />
  </xf:action>

event.status

The event.status value will indicate the status of the exchange. Codes used are based on HTTP return codes, although can apply to other protocols. For example, if a local file is not found, the status code will still be 404.

This allows the author to check for errors that they are happy to process:

  <xf:action
   ev:observer="sub-get-contact"
   ev:event="xforms-submit-data-received"
  >
    <xf:action if="(number(event()/status) = 404">
      ...
    </xf:action>
  </xf:action>