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

Re: Cancelling events

From: John Boyer <boyerj@ca.ibm.com>
Date: Wed, 31 Aug 2005 10:27:03 -0700
To: "Ben Cochran" <BCochran@ClubMom-inc.com>
Cc: www-forms@w3.org, www-forms-request@w3.org
Message-ID: <OF643E7575.74765423-ON8825706E.005F9C32-8825706E.005FE3E6@ca.ibm.com>
It's a little unclear what you want to do here.
Do you mean that you want to run the first submission but only 
conditionally run the second submission if certain conditions are true?

I think XML events is not very good at testing conditions for 
cancellation.

Or do you mean that you want to abort the whole sequence of operations 
until some conditions are met?

In that case, you can put a relevant condition on the node referenced by 
the trigger so that it cannot be activated by the user 
until the conditions are met.  It sounds more likely that this is what you 
really want, but it's hard to tell.

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





"Ben Cochran" <BCochran@ClubMom-inc.com> 
Sent by: www-forms-request@w3.org
08/30/2005 11:00 AM

To
<www-forms@w3.org>
cc

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 Wednesday, 31 August 2005 17:27:33 GMT

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