Hi,
I started the implementation of the part of the XForms spec regarding
the event() XPath function:
http://pastebin.com/uQvNZWXX
If this implementation seems the right one, it would be easier for
contributors to add contexts for other events.
EVENT CONTEXTS
----------------------------
To implement it, i added a XMLEvents.EventContexts stack that hold at
its top the event's context object
(a stack-of-associative-arrays).
The updating of this stack happens before and after sending the event,
in XMLEvents.dispatch(),
utilizing a try-finally structure to ensure no context objects left in
the stack in case of errors
(since the event functions are written by the author and may throw any
xforms-exception or errors).
DEFAULT EVENT PROPERTIES
------------------------------------
As a starting point, i added certain debug aids into the contexts for
all events, and this is *not* against the specs.
The extension properties are a subset of those described by Orbeon-Forms[1]
but without namespaces.
Maybe in a later step someone could add namespace support for the
event-property-names.
In particular, i added the following default-extension
event-properties into all event-contexts:
type: the name of the event;
targetid: the id of the event's target-element.
bubbles = 'true' if it is a bubbling event.
cancelable = 'true' if it is a cancelable event.
SUBMIT-ERROR EVENT PROPERTIES
-----------------------------------------------------
I added the following properties ONLY on "xforms-submt-error" event:
* STANDARD XForms event-properties:
method: see XForms-1.1, ch 11.5 [2]
resource-uri: see XForms-1.1, ch 11.5 [2]
error-type: see XForms-1.1, ch 11.5 [2]
response-status-code: see XForms-1.1, ch 11.5 [2]
response-reason-phrase: see XForms-1.1, ch 11.5 [2]
response-headers: see XForms-1.1, ch 11.5 [2], TODO: Parse
headers into nodes.
response-body: see XForms-1.1, ch 11.5 [2]
* XSLTForms EXTENSION event-properties
(better "standarize" those 2 throughout the code):
message: any js-exception message
stack-trace: any js-exception stack
NOTE 1: The code for adding event-context to the 'xforms-submit-error'
event is not 100% complete.
(although it took me 3-4 hours to do it)
* it checks for null-binding before sending a request (for 'no-data'
error-type) obeying to the xforms-spec, but does not evaluate the
binding to see if it is empty,
* it does not tries to discriminates submission errors after sending
request('parse-error' or 'target-error' error-type),
* it does not check cross-domain, neither post-form (METHOD="xml-url-encoded")
* it does not parses response-headers or response-body into nodesets.
There are some TODOs left in the patch about these points.
NOTE 2: The patch does not include changes into final files, you need
to build to generate them, before commiting the patch.
And since i still cannot manage to build the project, i hope i'm not
forgetting anything,
since i backported the changes from the final 'xsltforms.js' file
where i was testing them.
Regards,
kostis Anagnostopoulos
[1] http://wiki.orbeon.com/forms/doc/developer-guide/xforms-events#TOC-Enhanced-event-function-support
[2] http://www.w3.org/TR/xforms11/#submit-evt-submit-error
|