RE: Cancelling events

Hi Ben,
 
You can't cancel events conditionally, if that's what you mean. I have
proposed some extra XPath functions that would allow you to do this, but
they are still under discussion on the XForms Working Group.
 
Regards,
 
Mark
 

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/ 

 


  _____  

From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On Behalf
Of Ben Cochran
Sent: 30 August 2005 19:01
To: www-forms@w3.org
Subject: Cancelling events



What I'm looking for is a good solid example of how to cancel an event in
xforms. 

Specific case: I have a pair of models, one being submitted to an XML file
via 'put', the other going to a servlet via 'url-encoded-post'.  Both of
these models are being submitted "simultaneously," through two <send>
actions tied to a single <trigger>.

Now, rather than have logic in the servlet so as not to perform a DB update
if one of the values is empty, I'd rather just not send that submission at
all.  Particularly, what I'd like to do (I think) is cancel the
xforms-submit event before it hits the servlet-tied submission.  What I
can't figure out is how to do this.  As tests, I've tried adding
ev:defaultAction="cancel" and ev:propogate="stop" to the <send> actions;
adding ev:event="xforms-submit",  ev:propagate="stop", and
ev:defaultAction="cancel" to the servlet's <model> element.  I may well be
on the completely wrong track.  There seems to be precious little online or
in Xforms books that gives anything else other than listing the event-model
attributes and saying "you can cancel events."

Any help is appreciated. 


----Example Code Below---- 

<?xml version="1.0" encoding="UTF-8"?> 
<html 
        xmlns="http://www.w3.org/2002/06/xhtml2" 
        xmlns:xf="http://www.w3.org/2002/xforms" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:ev="http://www.w3.org/2001/xml-events"> 
        <head> 
                <title>Multiple Submission Test</title> 
                <xf:model id="servlet_model"> 
                        <xf:instance id="servlet_instance" xmlns=""> 
                                <servlet> 
                                        <value1/> 
                                        <value2/> 
                                </servlet> 
                        </xf:instance> 
                        <xf:submission id="servlet_submit"
action="TestServlet" method="url-encoded-post" separator="&amp;"
replace="none"/>

                </xf:model> 
                <xf:model id="xml_model"> 
                        <xf:instance id="xml_instance" xmlns=""> 
                                <document> 
                                        <foo> 
                                                <value1/> 
                                                <bar someattribute=""> 
                                                        <value2/> 
                                                </bar> 
                                        </foo> 
                                </document> 
                        </xf:instance> 
                        <xf:submission id="xml_submit"
action="file:///C:/somexml.xml" method="put" replace="none"/> 
                </xf:model> 
        </head> 
        <body> 
                <xf:group model="servlet_model"
ref="instance('servlet_instance')" appearance="full"> 
                        <xf:label>To Servlet</xf:label> 
                        <xf:input ref="value1" appearance="full"> 
                                <xf:label>Value 1 </xf:label> 
                        </xf:input> 
                        <xf:input ref="value2"> 
                                <xf:label>Value 2 </xf:label> 
                        </xf:input> 
                </xf:group> 
                <BR/> 
                <xf:group model="xml_model"
ref="instance('xml_instance')/foo" appearance="full"> 
                        <xf:label>To XML</xf:label> 
                        <xf:input ref="value1"> 
                                <xf:label>Value 1</xf:label> 
                        </xf:input> 
                        <xf:input ref="bar/@someattribute"> 
                                <xf:label>Some Attribute</xf:label> 
                        </xf:input> 
                        <xf:input ref="bar/value2"> 
                                <xf:label>Value 2</xf:label> 
                        </xf:input> 
                </xf:group> 
                <BR/> 
                <xf:group appearance="minimal"> 
                        <xf:trigger> 
                                <xf:label>Submit Both</xf:label> 
                                <xf:action ev:event="DOMActivate"> 
                                        <xf:send
submission="servlet_submit"/> 
                                        <xf:send submission="xml_submit"/> 
                                        <xf:load
resource="http://www.yahoo.com" show="replace"/> 
                                </xf:action> 
                        </xf:trigger> 
                </xf:group> 
        </body> 
</html> 

CMI Marketing, Inc.
Ben Cochran 
Technical Lead, Interface Engineering 
401 Park Avenue South
5th Floor
New York, New York 10016
tel 646.435.6508
fax 646.435.6600
www.clubmom.com 

Received on Friday, 2 September 2005 16:26:50 UTC