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

RE: How to use insert and delete actions

From: Mark Birbeck <mark.birbeck@x-port.net>
Date: Tue, 8 Feb 2005 11:57:09 -0000
To: "'Catherine Poinsignon'" <catherine.poinsignon@lombard.lu>
Cc: <www-forms@w3.org>
Message-ID: <008101c50dd5$54694f30$0c01a8c0@W100>

Catherine,

In addition to the incorrect evaluation context referred to by David, your
event registration is also wrong.

On the insertion, you haven't said what event you are listening for --
you've just put two event handlers inline in the xf:trigger. Try this
instead:

  <xf:trigger>
    <xf:label>New meeting</xf:label>
    <xf:action ev:event="DOMActivate">
      ... Your event handlers ...
    </xf:action>
  </xf:trigger>

On the delete, you have correctly put an xf:action with an event name of
'DOMActivate', but then you've put a further @ev:event on the handler that's
in the xf:action:

>  <xforms:action ev:event="DOMActivate">
>   <xforms:delete at="index('meetings_index')"
>      ev:event="activate" nodeset="meeting"/>
> </xforms:action>

As described in the spec [1] the xf:delete will never be activated, since it
is listening for the event 'activate' to appear on its parent element -- and
since it is an xf:action it will never receive it (although it's also the
wrong name). Remove this attribute and you should be OK (after fixing the
evaluation context).

Having said that, some implementations *incorrectly* process a xf:delete
action that has an @ev:event on it, so without knowing what implementation
you are using I can't say whether your xf:delete is being executed or not.
If it *is* being executed (which is wrong), then the evaluation problem
remains. If the implementation you are using does execute this, then I would
still recommend that you remove the extra @ev:event, since this will prevent
the action from being executed if you run your form on other processors that
do not run the action, due to [1].

Regards,

Mark

[1] http://www.w3.org/TR/xforms/slice10.html#action-action


Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

Download our XForms processor from
http://www.formsPlayer.com/

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On Behalf
Of Catherine Poinsignon
Sent: 08 February 2005 09:46
To: www-forms@w3.org
Subject: How to use insert and delete actions


Hi all,
I am trying to use the insert and delete actions to insert a new record in
my instance data or delete an existing record. Do do that, I hace the
following instance :

            <xforms:instance id="data"
                nweb:pageflow-replace-data="always"
nweb:primary-input-data="true">
                <meetings xmlns="">
                    <meeting day="monday" starthour="10.00">
                        <title>Sample meeting</title>
                    </meeting>
                </meetings>
            </xforms:instance>

I display the record using a repeat :

        <xforms:repeat id="meetings_index" nodeset="meeting">
                <xforms:input ref="title">
                    <xforms:label>Subject</xforms:label>
                </xforms:input>
                <xforms:select1 appearance="minimal" ref="@day">
                    <xforms:label>Day</xforms:label>
                    <xforms:choices>
    <xforms:item>
        <xforms:label>Monday</xforms:label>
        <xforms:value>monday</xforms:value>
    </xforms:item>
    <xforms:item>
        <xforms:label>Tuesday</xforms:label>
        <xforms:value>tuesday</xforms:value>
    </xforms:item>
    <xforms:item>
        <xforms:label>Wednesday</xforms:label>
        <xforms:value>wednesday</xforms:value>
    </xforms:item>
    <xforms:item>
        <xforms:label>Thursday</xforms:label>
        <xforms:value>thursday</xforms:value>
    </xforms:item>
    <xforms:item>
        <xforms:label>Friday</xforms:label>
        <xforms:value>friday</xforms:value>
    </xforms:item></xforms:choices>
                </xforms:select1>
                <xforms:select1 ref="@starthour">
                    <xforms:label>Sarts hour</xforms:label>
                    <xforms:choices>
 <xforms:item>
        <xforms:label>09.00</xforms:label>
        <xforms:value>09.00</xforms:value>
    </xforms:item>
    <xforms:item>
        <xforms:label>10.00</xforms:label>
        <xforms:value>10.00</xforms:value>
    </xforms:item>
 <xforms:item>
        <xforms:label>11.00</xforms:label>
        <xforms:value>11.00</xforms:value>
    </xforms:item>
 </xforms:choices>
                </xforms:select1>
                <xforms:trigger>
                    <xforms:label>Delete</xforms:label>
                    <xforms:action ev:event="DOMActivate">
      <xforms:delete at="index('meetings_index')"
                            ev:event="activate" nodeset="meeting"/>
                    </xforms:action>
                </xforms:trigger>
            </div>
        </xforms:repeat>

I wanted to add a new record by this trigger :

            <xforms:trigger>
                <xforms:label>New meeting</xforms:label>
    <xforms:insert at="index('meetings_index')"
                    nodeset="meeting" position="after"/>
    <xforms:setvalue ref="meeting[index('meetings_index')]/title">New
Meeting</xforms:setvalue>
            </xforms:trigger>

But it does not work : neither the delete, neither the new !!!
Could you please help me ?
Thanks in advance...

Catherine
Received on Tuesday, 8 February 2005 11:58:05 GMT

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