Forgive the simple question, but how can I pass a value into a control via an Action.
What I'm trying to achieve is to display a message popup with two buttons, and depending on the button pressed, I then want to populate a control value:
<xf:action observer="Message1-control" event="DOMActivate">
<xf:label>Alert Button</xf:label>
<xf:message>You pressed the Message 1 button</xf:message>
<!-- Here is where we want to write the value back to a control -->
</xf:action>
I've tried all sorts of synyax, but I'm struggling to get it right
I make demo form for you https://demo.orbeon.com/demo/fr/orbeon/builder/edit/2e978a87be5ce4112d9b008dd481ae935040861c
I use xxf:show
and xxf:dialog
to show modal popup with two controls. In button in modal I use xf:setvalue
to propagate value from input and xxf:hide
to hide window.
<xh:html xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xf="http://www.w3.org/2002/xforms">
<xh:head>
<xh:title>Untitled Form</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true" xxf:analysis.calculate="true">
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
<form>
<section-1>
<grid-1>
<AgeOutput/>
<BtnShowDialog/>
<btnDialogBox/>
<textBoxDialog/>
</grid-1>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="grid-1-bind" ref="grid-1" name="grid-1">
<xf:bind id="AgeOutput-bind" name="AgeOutput" ref="AgeOutput" xxf:whitespace="trim"/>
<xf:bind id="BtnShowDialog-bind" ref="BtnShowDialog" name="BtnShowDialog"/>
<xf:bind id="textBoxDialog-bind" name="textBoxDialog" ref="textBoxDialog"
xxf:whitespace="trim"/>
<xf:bind id="btnDialogBox-bind" ref="btnDialogBox" name="btnDialogBox"/>
</xf:bind>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance id="fr-form-metadata" xxf:readonly="true" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>test</application-name>
<form-name>age_dialog</form-name>
<title xml:lang="en">Untitled Form</title>
<description xml:lang="en"/>
<created-with-version>2021.1.6.202211071741 PE</created-with-version>
<library-versions>
<orbeon>14</orbeon>
<app>2</app>
</library-versions>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments" xxf:exclude-result-prefixes="#all">
<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">
<section-1>
<label>Untitled Section</label>
</section-1>
<AgeOutput>
<label/>
<hint/>
</AgeOutput>
<BtnShowDialog>
<label>Show dialog</label>
<hint/>
</BtnShowDialog>
<textBoxDialog>
<label>Age</label>
<hint/>
</textBoxDialog>
<btnDialogBox>
<label>Send</label>
<hint/>
</btnDialogBox>
</resource>
</resources>
</xf:instance>
</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-1-section" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid id="grid-1-grid" bind="grid-1-bind">
<fr:c y="1" x="1" w="6">
<xf:input id="AgeOutput-control" bind="AgeOutput-bind">
<xf:label ref="$form-resources/AgeOutput/label"/>
<xf:hint ref="$form-resources/AgeOutput/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
<fr:c y="1" x="7" w="6">
<xf:trigger id="BtnShowDialog-control" bind="BtnShowDialog-bind">
<xf:label ref="$form-resources/BtnShowDialog/label"/>
<xf:hint ref="$form-resources/BtnShowDialog/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xxf:show event="DOMActivate" dialog="my-dialog-id"/>
</xf:trigger>
</fr:c>
</fr:grid>
</fr:section>
<xxf:dialog id="my-dialog-id" appearance="full" level="modal" close="true" draggable="true"
visible="false">
<xf:label>Age confirm</xf:label>
<xf:input id="textBoxDialog-control" bind="textBoxDialog-bind">
<xf:label ref="$form-resources/textBoxDialog/label"/>
<xf:hint ref="$form-resources/textBoxDialog/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
<xf:trigger id="btnDialogBox-control" bind="btnDialogBox-bind">
<xf:label ref="$form-resources/btnDialogBox/label"/>
<xf:hint ref="$form-resources/btnDialogBox/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xf:action event="DOMActivate">
<!-- Operation to perform -->
<xf:setvalue ref="//AgeOutput" value="//textBoxDialog"/>
</xf:action>
<xxf:hide event="DOMActivate" dialog="my-dialog-id"/>
</xf:trigger>
</xxf:dialog>
</fr:body>
</fr:view>
</xh:body>
</xh:html>