W3C home > Mailing lists > Public > www-forms@w3.org > October 2011

XForms 1.1 xforms-select event

From: Derksen, Marc <mmbderksen@Seneca.nl>
Date: Tue, 18 Oct 2011 17:28:09 +0200
To: "www-forms@w3.org" <www-forms@w3.org>
Message-ID: <75E7B21D8A13D44CAE0ED2AE2DE3354024C982FB@SIMX02.Seneca.Intern>
When a case in a switch is selected by using a toggle, the xforms-select event is sent to the selected case element.
Shouldn't this event also be dispatched, to the selected case element, during the initial rendering of the form?
This scenario is not described in the specs.

Look at the example below. Case with id "step_2" is initially selected due to the selected="true" attribute.
The currentStep value is set by the setvalue that listens to the xforms-select event.
If this event is not fired during initial rendering, I need to add redundant (and error-prone) state information to set its initial value.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
	<head>
		<title>XForm with switch</title>
		<xf:model>
			<xf:instance xmlns="">
				<root>
					<currentStep>not set</currentStep>
				</root>
			</xf:instance>
		</xf:model>
	</head>
	<body>
		<xf:output ref="currentStep">
			<xf:label>Instance data: </xf:label>
		</xf:output>
		<xf:switch>
			<xf:case id="step_1">
				<xf:label>Step 1</xf:label>
				<xf:output value="1">
					<xf:label>Step </xf:label>
				</xf:output>
				<xf:setvalue ref="currentStep" value="1" ev:event="xforms-select" />
			</xf:case>
			<xf:case id="step_2" selected="true">
				<xf:label>Step 2</xf:label>
				<xf:output value="2">
					<xf:label>Step </xf:label>
				</xf:output>
				<xf:setvalue ref="currentStep" value="2" ev:event="xforms-select" />
			</xf:case>
			<xf:case id="step_3">
				<xf:label>Step 3</xf:label>
				<xf:output value="3">
					<xf:label>Step </xf:label>
				</xf:output>
				<xf:setvalue ref="currentStep" value="3" ev:event="xforms-select" />
			</xf:case>
		</xf:switch>
		<xf:trigger>
			<xf:label>Goto step 1</xf:label>
			<xf:toggle case="step_1" ev:event="DOMActivate" />
		</xf:trigger>
		<xf:trigger>
			<xf:label>Goto step 2</xf:label>
			<xf:toggle case="step_2" ev:event="DOMActivate" />
		</xf:trigger>
		<xf:trigger>
			<xf:label>Goto step 3</xf:label>
			<xf:toggle case="step_3" ev:event="DOMActivate" />
		</xf:trigger>
	</body>
</html>

Kind regards,
 
Marc Derksen
Received on Tuesday, 18 October 2011 16:38:30 GMT

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