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