W3C home > Mailing lists > Public > www-forms@w3.org > September 2006

Re: Nested repeat and xf:delete question ...

From: John Boyer <boyerj@ca.ibm.com>
Date: Mon, 18 Sep 2006 11:09:00 -0700
To: Sébastien CRAMATTE <contact@zeninteractif.com>
Cc: Xforms W3C Mailing list <www-forms@w3.org>, www-forms-request@w3.org
Message-ID: <OF35C675A0.32190415-ON882571ED.00626394-882571ED.0063B500@ca.ibm.com>
Hi Sebastien,

There are basically two patterns you would use for a "delete button" (by 
which I mean a trigger with a delete action attached to the DOMActivate 

The first is to have the trigger inside the repeat and the other is to 
have it outside the repeat.

When a deletion trigger appears outside of a repeat, the delete action 
typically has a nodeset attribute with the same nodeset expression as the 
repeat, and the at attribute uses the index() function to cause deletion 
of the node of data corresponding to the current row of the repeat.

When a deletion trigger appears inside of a repeat, it is duplicated on 
every row of the repeat, so the deletion trigger and hence the delete 
action already have an in-scope evaluation context equal to the very node 
you would like to delete.  So, instead of setting the nodeset attribute 
equal to the same thing as the repeat, you have to recognize that the 
repeat itself is already giving the correct context to the delete action. 
So, you only have to say <delete nodeset="." at="1"/> and you're done.

I think the confusion you were having about the 'at' attribute is because 
you were trying to set up the deletion trigger as if it were not inside 
the repeat.  It turns out that you can do this too.  And, the whole delete 
action looks almost identical when it is inside versus when it is outside 
of the repeat.  So, you should also be able to write your delete below as 

<form:delete ev:event="DOMActivate" nodeset="../concentre:feature" 
at="index('repeat-features')" />

This version of the at attribute works because when the user activates the 
delete trigger, the very first thing an XForms implementation does is set 
the index of the repeat so that the row containing the input focus is 
regarded as the "current" row of the repeat.

As you correctly deduced, the nodeset attribute required the leading ../ 
because the repeat sets the in-scope evaluation context to be a particular 
concentre:feature, which differs on each row, so you back up to the parent 
of the homogeneous collection of concentre:feature elements, then select 
them all.  The 'at' attribute then chooses the one corresponding to the 
row containing the trigger you just activated.

Best regards,
John M. Boyer, Ph.D.
Senior Product Architect/Research Scientist
Co-Chair, W3C XForms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@ca.ibm.com  http://www.ibm.com/software/

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer

Sébastien CRAMATTE <contact@zeninteractif.com> 
Sent by: www-forms-request@w3.org
09/18/2006 08:50 AM

Xforms W3C Mailing list <www-forms@w3.org>

Nested repeat  and xf:delete  question ...

Hello list,

I've made this forms. It use nested repeat and works quite well.
My only problem is that I want to put delete trigger  in  nested-repeat
to delete a specific line
but I don't know which value I should put in @at  attribute .... Look at
button  "Delete this feature"

I hope that someone have got the answer or any tips

            <form:repeat nodeset="concentre:release" id="repeat-release">
              <form:input ref="concentre:label" >
                    <form:group ref="concentre:features"
                    <form:repeat nodeset="concentre:feature"

                      <form:input ref="concentre:label" >
                      <form:select1 ref="concentre:status"
<form:value>todo</form:value>  </form:item>
<form:value>done</form:value> </form:item>
                        <form:item><form:label>Working on</form:label>
<form:value>workingon</form:value> </form:item>
<form:value>discarded</form:value> </form:item>
                        <form:label>Delete this feature</form:label>
                        <form:delete ev:event="DOMActivate"
nodeset="../concentre:feature" at="1" />
                <form:label>Add a feature</form:label>
                <form:insert ev:event="DOMActivate"
nodeset="concentre:feature" at="last()" position="after"/>

                <form:label>Add release</form:label>
                <form:insert ev:event="DOMActivate"
nodeset="concentre:release" at="last()" position="after"/>
Received on Monday, 18 September 2006 18:09:27 UTC

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