W3C home > Mailing lists > Public > www-forms@w3.org > August 2005

Re: xforms:choose within xforms:repeat

From: Peter Nunn <peter.nunn@vistic-sw.com>
Date: Wed, 17 Aug 2005 12:20:19 +1200
Message-ID: <430282C3.4090303@vistic-sw.com>
To: www-forms@w3.org

Erik Bruchez wrote:

> All,
> From the 1.0 spec, section 9.3.10:
> "A necessary consequence of this is that XForms 1.0 does not specify 
> the behavior of construct switch within element repeat. Future 
> versions of XForms may specify the behavior of switch inside repeat 
> based on implementation experience and user feedback."
> Any thoughts about what possible behaviors could be? I see two:
> 1. All the repeated switches show the same case element and switch at 
> the same time.
> 2. Somehow, a particular switch only switches, maybe based on the 
> source of the initial event causing the toggle action.
> I don't think #1 is very satisfying, and I am not too sure about the 
> consequences of #2. Any other thoughts on the subject? Should the 
> toggle action take one or more repeat ids / indexes as parameters?
> Actual users are likely to hit this snag. See for example this initial 
> post on ops-users:
>   http://mail-archive.objectweb.org/ops-users/2005-08/msg00069.html
> -Erik

Have used the behaviour of the formsplayer implementation which works really well in real-world applications, and have implemented it in a javascript xforms implementation.
The switch..case is local to the context which the toggle is contained within.
 The first switch with the id equal to the toggle case statement is used.  If the toggle is fired outside a repeat action then the code should toggle the prototype case statement and any new rows added to the repeat should then copy the prototype repeat row and toggle/case settings.

So it goes like this:
Each prototype row has the case id cloned.
A toggle activated on a row bubles up to the first case statement so that if it is inside a repeat it will find the cloned repeat, if not inside the repeat it will bubble to the root document.
If the toggle case was not handled the toggle will then search the dom down till it finds a case matching the toggle ID.  This will of course find the prototype repeat element and the case will be processed at that level.
The next row inserted into the repeat will then take on the toggle value.

This will work for all possible toggle cases.

Received on Wednesday, 17 August 2005 00:26:55 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:15 UTC