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 
event).

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 
follows: 

<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

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

Subject
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
Regards


            <form:repeat nodeset="concentre:release" id="repeat-release">
                <form:group>
                    <form:label>Release</form:label>
 
              <form:input ref="concentre:label" >
                       <form:label>Label:</form:label>
                   </form:input>
 
                    <form:group ref="concentre:features"
appearance="minimal">
                    <form:repeat nodeset="concentre:feature"
id="repeat-features">
                        <form:group>
                            <form:label>Feature</form:label>

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

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

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:06 GMT