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

Cancelling events

From: Ben Cochran <BCochran@ClubMom-inc.com>
Date: Tue, 30 Aug 2005 14:00:46 -0400
Message-ID: <013418E6EE2BE040A334C44449EFF03003BFFC@exchange.clubmom.local>
To: <www-forms@w3.org>
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"?>
		<title>Multiple Submission Test</title>
		<xf:model id="servlet_model">
			<xf:instance id="servlet_instance" xmlns="">
			<xf:submission id="servlet_submit" action="TestServlet" method="url-encoded-post" separator="&amp;" replace="none"/>
		<xf:model id="xml_model">
			<xf:instance id="xml_instance" xmlns="">
						<bar someattribute="">
			<xf:submission id="xml_submit" action="file:///C:/somexml.xml" method="put" replace="none"/>
		<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 ref="value2">
				<xf:label>Value 2 </xf:label>
		<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 ref="bar/@someattribute">
				<xf:label>Some Attribute</xf:label>
			<xf:input ref="bar/value2">
				<xf:label>Value 2</xf:label>
		<xf:group appearance="minimal">
				<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"/>

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 
Received on Tuesday, 30 August 2005 18:56:55 UTC

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