XForms 1.1 xforms-select event
"Derksen, Marc" <[email protected]> Tue, 18 Oct 2011 17:28:09 +0200
| Newsgroups | gmane.comp.web.xforms |
|---|---|
| Message-ID | <[email protected]> |
When a case in a switch is selected by using a toggle, the xforms-select ev= ent is sent to the selected case element. Shouldn't this event also be dispatched, to the selected case element, duri= ng 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=3D"true" attribute. The currentStep value is set by the setvalue that listens to the xforms-sel= ect event. If this event is not fired during initial rendering, I need to add redundan= t (and error-prone) state information to set its initial value. <?xml version=3D"1.0" encoding=3D"UTF-8"?> <html xmlns=3D"http://www.w3.org/1999/xhtml" xmlns:xf=3D"http://www.w3.org/= 2002/xforms" xmlns:ev=3D"http://www.w3.org/2001/xml-events"> <head> <title>XForm with switch</title> <xf:model> <xf:instance xmlns=3D""> <root> <currentStep>not set</currentStep> </root> </xf:instance> </xf:model> </head> <body> <xf:output ref=3D"currentStep"> <xf:label>Instance data: </xf:label> </xf:output> <xf:switch> <xf:case id=3D"step_1"> <xf:label>Step 1</xf:label> <xf:output value=3D"1"> <xf:label>Step </xf:label> </xf:output> <xf:setvalue ref=3D"currentStep" value=3D"1" ev:event=3D"xforms-select"= /> </xf:case> <xf:case id=3D"step_2" selected=3D"true"> <xf:label>Step 2</xf:label> <xf:output value=3D"2"> <xf:label>Step </xf:label> </xf:output> <xf:setvalue ref=3D"currentStep" value=3D"2" ev:event=3D"xforms-select"= /> </xf:case> <xf:case id=3D"step_3"> <xf:label>Step 3</xf:label> <xf:output value=3D"3"> <xf:label>Step </xf:label> </xf:output> <xf:setvalue ref=3D"currentStep" value=3D"3" ev:event=3D"xforms-select"= /> </xf:case> </xf:switch> <xf:trigger> <xf:label>Goto step 1</xf:label> <xf:toggle case=3D"step_1" ev:event=3D"DOMActivate" /> </xf:trigger> <xf:trigger> <xf:label>Goto step 2</xf:label> <xf:toggle case=3D"step_2" ev:event=3D"DOMActivate" /> </xf:trigger> <xf:trigger> <xf:label>Goto step 3</xf:label> <xf:toggle case=3D"step_3" ev:event=3D"DOMActivate" /> </xf:trigger> </body> </html> Kind regards, =A0 Marc Derksen