W3C home > Mailing lists > Public > public-forms@w3.org > December 2011

Repeats and events

From: Erik Bruchez <ebruchez@orbeon.com>
Date: Mon, 12 Dec 2011 15:48:26 -0800
Message-ID: <CAAc0PEW-s+MJRdvc-MDywU2OLzCToYbRYsbmBgbZkaq_Mzw5xg@mail.gmail.com>
To: public-forms@w3.org
All,

I have a question about repeats and events, which I am not sure is
addressed in the spec (at least not explicitly).

In XForms 1.1, there is the concept of "repeat objects" which
represent runtime repeat iterations. XForms1.1 states:

"A repeat object is an implicitly generated group element that
contains the set of run-time objects generated to represent the repeat
template content for a single repeat item of the repeat collection.
These run-time objects are form controls, XForms actions and other
host language elements that correspond to elements in the repeat
template."

Less formally, XForms 1.1 also mentions the "repeat container"
control, which manages the "repeat collection".

Now, let's say we have this repeat with a nested event handler:

<xforms:repeat ref="value" id="my-repeat">
    <xforms:action ev:event="my-event"/>
</xforms:repeat>

And I dispatch, from outside the repeat, an event using the repeat id:

<xforms:dispatch targetid="my-repeat" name="my-event"/>

The three-pronged question is:

1. Does the handler run, or not?
2. If so, does it run once, or once per repeat iteration?
3. If it runs only once, in which XPath context does the action run?

There seems to be 2 basic options:

Option A. If you assume that the id corresponds to the repeat
container, then it should not respond to the event, as the actual
markup would look like:

<xforms:repeat ref="value" id="my-repeat">
    <xforms:group ref=".">
        <xforms:action ev:event="my-event"/>
    </xforms:group>
    ...
</xforms:repeat>

Option B. However, if the id corresponds to the repeat iteration, then
it should respond to the event, as if you had written:

<xforms:repeat ref="value">
    <xforms:group id="my-repeat" ref=".">
        <xforms:action ev:event="my-event"/>
    </xforms:group>
    ...
</xforms:repeat>

Further, in the latter case, the event handler would run in the XPath
context of the iteration with the current repeat index.

There are benefits and drawbacks to each option. Option A makes sense
once you explain to the programmer that even though he can't see it,
there is a virtual <group> in between. However, this doesn't allow
placing within xforms:repeat a handler that responds directly to an
event directed to that repeat by id.

Option B makes sense in that if you just look at the markup, it might
be more intuitive that a handler responds to an event directed to that
repeat by id. On the other hand, it makes making a distinction between
events targeting a repeat iteration vs. the repeat as a whole more
difficult.

Is there an option C?

-Erik
Received on Monday, 12 December 2011 23:49:15 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 October 2013 22:06:56 UTC