Created
February 2, 2017 19:00
-
-
Save avernet/1afe4be80f69faeb3b1708dfd1fc0829 to your computer and use it in GitHub Desktop.
Dropdown inside repeat depending on value of dropdown outside repeat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" | |
xmlns:xxf="http://orbeon.org/oxf/xml/xforms" | |
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" | |
xmlns:saxon="http://saxon.sf.net/" | |
xmlns:fr="http://orbeon.org/oxf/xml/form-runner" | |
xmlns:xf="http://www.w3.org/2002/xforms" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:sql="http://orbeon.org/oxf/xml/sql" | |
xmlns:ev="http://www.w3.org/2001/xml-events" | |
xmlns:xi="http://www.w3.org/2001/XInclude" | |
xmlns:exf="http://www.exforms.org/exf/1-0" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:fb="http://orbeon.org/oxf/xml/form-builder" | |
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
<xh:head> | |
<xh:title>Untitled Form</xh:title> | |
<xf:model id="fr-form-model" xxf:expose-xpath-types="true"> | |
<!-- Main instance --> | |
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id"> | |
<form> | |
<section-5> | |
<states itemset-empty="false">AK</states> | |
</section-5> | |
<section-1> | |
<grid-2> | |
<grid-2-iteration> | |
<cities/> | |
</grid-2-iteration> | |
</grid-2> | |
</section-1> | |
</form> | |
</xf:instance> | |
<!-- Bindings --> | |
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')"> | |
<xf:bind id="section-5-bind" ref="section-5" name="section-5"> | |
<xf:bind id="states-bind" ref="states" name="states"/> | |
</xf:bind> | |
<xf:bind id="section-1-bind" name="section-1" ref="section-1"> | |
<xf:bind id="grid-2-bind" ref="grid-2" name="grid-2"> | |
<xf:bind id="grid-2-iteration-bind" ref="grid-2-iteration" name="grid-2-iteration"> | |
<xf:bind id="cities-bind" ref="cities" name="cities"/> | |
</xf:bind> | |
</xf:bind> | |
</xf:bind> | |
</xf:bind> | |
<!-- Metadata --> | |
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all"> | |
<metadata> | |
<application-name>a</application-name> | |
<form-name>a</form-name> | |
<title xml:lang="en">Untitled Form</title> | |
<description xml:lang="en"/> | |
</metadata> | |
</xf:instance> | |
<!-- Attachments --> | |
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all"> | |
<attachments> | |
<css mediatype="text/css" filename="" size=""/> | |
<pdf mediatype="application/pdf" filename="" size=""/> | |
</attachments> | |
</xf:instance> | |
<!-- All form resources --> | |
<xf:instance xxf:readonly="true" id="fr-form-resources" xxf:exclude-result-prefixes="#all"> | |
<resources> | |
<resource xml:lang="en"> | |
<states> | |
<label>States</label> | |
<hint/> | |
</states> | |
<cities> | |
<label>Cities</label> | |
<hint/> | |
<item> | |
<label>First choice</label> | |
<value>1</value> | |
</item> | |
<item> | |
<label>Second choice</label> | |
<value>2</value> | |
</item> | |
<item> | |
<label>Third choice</label> | |
<value>3</value> | |
</item> | |
</cities> | |
<section-1> | |
<label>Cities</label> | |
</section-1> | |
<section-5> | |
<label>States</label> | |
<help/> | |
</section-5> | |
</resource> | |
</resources> | |
</xf:instance> | |
<xf:instance xxf:readonly="true" xxf:exclude-result-prefixes="#all" id="grid-2-template"> | |
<grid-2-iteration> | |
<cities/> | |
</grid-2-iteration> | |
</xf:instance> | |
<xf:instance id="cities-instance" class="fr-service" xxf:exclude-result-prefixes="#all"> | |
<body xmlns:fbf="java:org.orbeon.oxf.fb.FormBuilder" | |
xmlns:secure="java:org.orbeon.oxf.util.SecureUtils" | |
xmlns:p="http://www.orbeon.com/oxf/pipeline" | |
xmlns:frf="java:org.orbeon.oxf.fr.FormRunner"><params> | |
<state-abbreviation/> | |
</params></body> | |
</xf:instance> | |
<xf:submission id="cities-submission" class="fr-service" | |
ref="instance('fr-service-request-instance')" | |
resource="/xforms-sandbox/service/zip-cities" | |
method="get" | |
serialization="application/x-www-form-urlencoded" | |
mediatype="application/x-www-form-urlencoded" | |
replace="instance" | |
instance="fr-service-response-instance"/> | |
<xf:action id="cities-binding"> | |
<!-- React to event... on control... --> | |
<xf:action event="xforms-value-changed xforms-enabled" ev:observer="states-control" | |
if="true()"> | |
<!-- Service to call --> | |
<xf:send submission="cities-submission"/> | |
</xf:action> | |
<!-- Request actions --> | |
<xf:action event="xforms-submit" ev:observer="cities-submission"> | |
<!-- Get reference to initial request --> | |
<xf:var name="request-instance-name" value="'cities-instance'" as="xs:string"/> | |
<!-- Copy over to read-write request instance --> | |
<xf:insert ref="instance('fr-service-request-instance')" | |
origin="saxon:parse(instance($request-instance-name))"/> | |
<!-- Set values if needed --> | |
<xf:action context="instance('fr-service-request-instance')"> | |
<xf:action class="fr-set-service-value-action"> | |
<xf:var name="control-name" value="'states'"/> | |
<xf:var name="path" value="/*/state-abbreviation"/> | |
</xf:action> | |
<!-- Setvalue actions will be here --> | |
</xf:action> | |
</xf:action> | |
<!-- Response actions --> | |
<xf:action event="xforms-submit-done" ev:observer="cities-submission" | |
context="instance('fr-service-response-instance')"> | |
<xf:action class="fr-itemset-action"> | |
<xf:var name="control-name" value="'cities'"/> | |
<xf:var name="response-items" value="/cities/city"/> | |
<xf:var name="item-label" value="@name"/> | |
<xf:var name="item-value" value="@name"/> | |
</xf:action> | |
<!-- Response actions will be here --> | |
</xf:action> | |
</xf:action> | |
</xf:model> | |
</xh:head> | |
<xh:body> | |
<fr:view> | |
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:p="http://www.orbeon.com/oxf/pipeline" | |
xmlns:oxf="http://www.orbeon.com/oxf/processors"> | |
<fr:section id="section-5-control" bind="section-5-bind"> | |
<xf:label ref="$form-resources/section-5/label"/> | |
<fr:grid> | |
<xh:tr> | |
<xh:td> | |
<fr:databound-select1 xmlns="http://orbeon.org/oxf/xml/form-builder" | |
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" | |
id="states-control" | |
resource="/xforms-sandbox/service/zip-states" | |
bind="states-bind"> | |
<xf:label ref="$form-resources/states/label"/> | |
<xf:hint ref="$form-resources/states/hint"/> | |
<xf:alert ref="$fr-resources/detail/labels/alert"/> | |
<xf:itemset ref="/states/state"> | |
<xf:label ref="@name"/> | |
<xf:value ref="@abbreviation"/> | |
</xf:itemset> | |
</fr:databound-select1> | |
</xh:td> | |
</xh:tr> | |
</fr:grid> | |
</fr:section> | |
<fr:section id="section-1-control" bind="section-1-bind"> | |
<xf:label ref="$form-resources/section-1/label"/> | |
<fr:grid id="grid-2-grid" bind="grid-2-bind" repeat="content" min="1" | |
template="instance('grid-2-template')" | |
apply-defaults="true" | |
fb:initial-iterations="first"> | |
<xh:tr> | |
<xh:td> | |
<xf:select1 id="cities-control" bind="cities-bind" appearance="dropdown"> | |
<xf:label ref="$form-resources/cities/label"/> | |
<xf:hint ref="$form-resources/cities/hint"/> | |
<xf:alert ref="$fr-resources/detail/labels/alert"/> | |
<xf:itemset ref="$form-resources/cities/item"> | |
<xf:label ref="label"/> | |
<xf:value ref="value"/> | |
</xf:itemset> | |
</xf:select1> | |
</xh:td> | |
</xh:tr> | |
</fr:grid> | |
</fr:section> | |
</fr:body> | |
</fr:view> | |
</xh:body> | |
</xh:html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment