orbeon link concat value in href - hyperlink

How can I create a dynamic link with a value as part of the url in a xh:a link in orbeon?
<x131573079 type="input"/>
<xh:a target="_blank" href="concat('http://www.someurl.nl/new?code=', $x131573079)">linkwithcode</xh:a></xh:div>
I have created a minimum set too display the problem. The
I created a minimum set the display the issue. The {concat()} does not work in this case...
<?xml version="1.0" encoding="UTF-8"?>
<xh:head xml:lang="nl">
<xh:title>hyperlink</xh:title>
<xf:model id="fr-form-model" xxf:revisit-handling="reload" xxf:noscript-support="true">
<xf:instance id="fr-form-instance">
<form group-name="patrickgroep" form-name="hyperlink" form-title="">
<formname>hyperlink</formname>
<formtitle/>
<groupname>patrickgroep</groupname>
<tab_nav>
<tab_1 idx="1" name="x124675808" visibility="opened">true()</tab_1>
</tab_nav>
<x124675808 type="tab" tabidx="1">
<x124412365 type="block" layout="vertical" in_overview="true">
<x131573079 type="input" prefill="nu2"/>
<x177054053 type="output"/>
</x124412365>
<error_count/>
</x124675808>
<x124675808nav-button/>
</form>
</xf:instance>
<xf:bind id="fr-form-binds" ref="instance('fr-form-instance')">
<xf:bind id="formname-bind" ref="formname" name="formname"/>
<xf:bind id="formtitle-bind" ref="formtitle" name="formtitle"/>
<xf:bind id="groupname-bind" ref="groupname" name="groupname"/>
<xf:bind id="x124675808-bind" ref="x124675808" relevant="true()">
<xf:bind id="x124412365-bind" ref="x124412365" relevant="true()">
<xf:bind id="x131573079-bind" ref="x131573079" name="x131573079"
required="false()" readonly="false()" xxf:default="nu"/>
<xf:bind id="x177054053-bind" ref="x177054053"
calculate="if (xxf:evaluate-bind-property('x124412365-bind', 'relevant')) then (concat('http://somesite.com/page?code=',$x131573079)) else ''"
/>
</xf:bind>
</xf:bind>
</xf:bind>
<xf:instance id="fr-form-resources" xxf:cache="true">
<resources>
<resource xml:lang="nl">
<x124675808>
<label>MyTab</label>
</x124675808>
<x124412365>
<title/>
</x124412365>
<x131573079>
<label>vraag</label>
</x131573079>
<x177054053>
<label>whatever</label>
</x177054053>
</resource>
</resources>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<xh:div id="variables"/>
<fr:view>
<xf:label ref="instance('fr-form-metadata')/title"/>
<fr:body>
<xf:group xxf:update="full" id="x124675808-section" bind="x124675808-bind"
class="tab-{if(xxf:instance('fr-form-instance')/tab_nav/tab_1='true()') then 'visible' else 'hidden'}">
<xh:h2 class="section-header">
<xf:output id="x124675808-title-text" mediatype="text/html"
ref="$form-resources/x124675808/label"/>
</xh:h2>
<xf:group id="x124675808-group">
<xf:group id="x124412365" bind="x124412365-bind"
class="default-block block-layout-vertical">
<xh:div id="x124412365-content">
<xh:div id="x131573079-content-item" class="block-layout-vertical">
<xf:input bind="x131573079-bind" id="x131573079-control">
<xf:label>
<xf:output id="x131573079-label-outputtext"
mediatype="text/html"
ref="$form-resources/x131573079/label"/>
</xf:label>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:div>
<xh:div id="x177054053-content-item" class="block-layout-vertical">
<xf:output bind="x177054053-bind" id="x177054053-control"
mediatype="text/html"/>
</xh:div>
<xh:div>
<xh:a target="_target"
href="{concat('http://somesite.com/page?code=',$x131573079)}"
>somesite.com</xh:a>
</xh:div>
</xh:div>
</xf:group>
</xf:group>
</xf:group>
</fr:body>
</fr:view>
</xh:body>

It's very simple, you just need to add {} in the attribute, and what is inside the curly brackets will be evaluated as an XPath expression:
<xh:a target="_blank"
href="{concat('http://www.someurl.nl/new?code=', $x131573079)}">
linkwithcode
</xh:a>

It seems I have fixed the issue with the following post: Orbeon Form Builder - hyperlink with dynamic url?
using this:
<xh:a target="_target" id="123"
href="http://www.nu.nl/code={x131573079}"
>somesite.com</xh:a>

Related

Orbeon Forms: How to populate a control value via an Action

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>

How to count the number of duplicate repeated grid - orbeon 2020.1CE

It needs to implement a mechanism that will count the number of repeated grids and send the value to the dedicated cell (named x).
If check box - First choice is unchecked, repeated grid is hidden and cell x must show "0".
If check box - First choice is checked, repeated grid become visible and cell x must show "1", and increase by 1 for each addition of repeated grid.
What expression I need to use in cell x?
If in your repeated grid you have a field named first-name, the expression count($first-name) used in a control outside of the repeated grid returns the number of rows in your repeated grid. Assuming your checkbox field is named checkbox, your expression would look like:
if ($checkbox/string() = 'true')
then count($first-name)
else 0
You can find the source of a test form that shows this in action below, and at runtime you get something like:
<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>Counting the number of rows in a repeated grid</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>
<checkbox question-identifier="">true</checkbox>
<count question-identifier=""/>
</grid-1>
<grid-2>
<grid-2-iteration>
<first-name question-identifier=""/>
</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-1-bind" name="section-1" ref="section-1">
<xf:bind id="grid-1-bind" ref="grid-1" name="grid-1">
<xf:bind id="count-bind" name="count" ref="count" xxf:whitespace="trim"
calculate="if ($checkbox/string() = 'true')
then count($first-name)
else 0"
readonly="false()"/>
<xf:bind id="checkbox-bind" ref="checkbox" name="checkbox" type="xf:boolean"/>
</xf:bind>
<xf:bind id="grid-2-bind" ref="grid-2" name="grid-2"
relevant="$checkbox/string() = 'true'">
<xf:bind id="grid-2-iteration-bind" ref="grid-2-iteration" name="grid-2-iteration">
<xf:bind id="first-name-bind" ref="first-name" name="first-name" xxf:whitespace="trim"/>
</xf:bind>
</xf:bind>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance id="fr-form-metadata" xxf:readonly="true" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>a</application-name>
<form-name>a</form-name>
<title xml:lang="en">Counting the number of rows in a repeated grid</title>
<description xml:lang="en"/>
<created-with-version>2019.1-SNAPSHOT PE</created-with-version>
<library-versions>
<orbeon>1</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">
<checkbox>
<label>Show repeated grid</label>
<hint/>
</checkbox>
<count>
<label>Count</label>
<hint/>
</count>
<first-name>
<label>First name</label>
<hint/>
</first-name>
<section-1>
<label>Untitled Section</label>
</section-1>
</resource>
</resources>
</xf:instance>
<xf:instance xxf:readonly="true" id="grid-2-template" xxf:exclude-result-prefixes="#all">
<grid-2-iteration>
<first-name/>
</grid-2-iteration>
</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">
<fr:checkbox-input id="checkbox-control" bind="checkbox-bind">
<xf:label ref="$form-resources/checkbox/label"/>
<xf:hint ref="$form-resources/checkbox/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</fr:checkbox-input>
</fr:c>
<fr:c y="1" x="7" w="6">
<xf:input id="count-control" bind="count-bind">
<xf:label ref="$form-resources/count/label"/>
<xf:hint ref="$form-resources/count/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
</fr:grid>
<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">
<fr:c x="1" y="1" w="6">
<xf:input id="first-name-control" bind="first-name-bind">
<xf:label ref="$form-resources/first-name/label"/>
<xf:hint ref="$form-resources/first-name/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</fr:c>
<fr:c x="7" y="1" w="6"/>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>

Orbeon preselect autocomplete value in reusable component

I'm using Orbeon v2017.1 and I'm trying to create a service within a Section Template which is supposed to retrieve the label of the default country which should be preselected in an autocomplete field (country).
I want to preselect the country only if the user has not entered a value (or, when the form loads). It should support multiple languages.
If I trigger the action after "form loads" and after "the controls are ready", it calls my service but only for the library form. For all other forms which include this reusable section, the service is not called.
Is there some other way this could be achieved? Thanks in advance.
EDIT
Below is an example of an autocomplete field, service, and action which sets the control value
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
<xh:title/>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance id="all-countries"
src="http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso/ListOfCountryNamesByName/XML"/>
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
<form>
<section-1>
<country-dynamic-autocomplete label=""/>
</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="country-dynamic-autocomplete-bind" ref="country-dynamic-autocomplete"
name="country-dynamic-autocomplete"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>insurance</application-name>
<form-name>test</form-name>
<title xml:lang="en"/>
<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 -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<country-dynamic-autocomplete>
<label>Countries Preselect Value</label>
<hint/>
</country-dynamic-autocomplete>
<section-1>
<label>Country Section</label>
</section-1>
</resource>
</resources>
</xf:instance>
<xf:instance id="get-default-country-value-instance" class="fr-service"
xxf:exclude-result-prefixes="#all">
<body xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:fbf="java:org.orbeon.oxf.fb.FormBuilder"><params/></body>
</xf:instance>
<xf:submission id="get-default-country-value-submission" class="fr-service"
resource="http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso/CountryName/XML/debug?sCountryISOCode=DE"
method="get"
serialization="none"
mediatype="none"/>
<xf:action id="set-country-default-value-binding">
<xf:action event="DOMActivate" ev:observer="country-dynamic-autocomplete-control"
if="true()">
<xf:send submission="get-default-country-value-submission"/>
</xf:action>
<xf:action event="xforms-submit" ev:observer="get-default-country-value-submission">
<xf:var name="request-instance-name" value="'get-default-country-value-instance'"/>
<xf:action/>
</xf:action>
<xf:action event="xforms-submit-done" ev:observer="get-default-country-value-submission">
<xf:action class="fr-set-control-value-action">
<xf:var name="control-name" value="'country-dynamic-autocomplete'"/>
<xf:var name="control-value" value="/string"/>
</xf:action>
</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-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<fr:autocomplete xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
id="country-dynamic-autocomplete-control"
labelref="#label"
max-results-displayed="300"
resource="http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso/ListOfCountryNamesByName/XML"
bind="country-dynamic-autocomplete-bind">
<xf:label ref="$form-resources/country-dynamic-autocomplete/label"/>
<xf:hint ref="$form-resources/country-dynamic-autocomplete/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xf:itemset ref="/ArrayOftCountryCodeAndName/tCountryCodeAndName">
<xf:label ref="sName"/>
<xf:value ref="sISOCode"/>
</xf:itemset>
</fr:autocomplete>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
EDIT 2 (new service):
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude">
<xh:head>
<xh:title/>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance id="all-countries" src="http://api.worldbank.org/v2/countries/"/>
<!-- Main instance --> <xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all" xxf:index="id">
<form>
<section-1>
<country-dynamic-autocomplete label=""/>
<control-3/>
</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="country-dynamic-autocomplete-bind" ref="country-dynamic-autocomplete"
name="country-dynamic-autocomplete"/>
<xf:bind id="control-3-bind" ref="control-3" name="control-3" xxf:whitespace="trim"/>
</xf:bind>
</xf:bind>
<!-- Metadata --> <xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>insurance</application-name>
<form-name>test</form-name>
<title xml:lang="en"/>
<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 --> <!-- Don't make readonly by default in case a service modifies the resources --> <xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<country-dynamic-autocomplete>
<label>Countries Preselect Value</label>
<hint/>
</country-dynamic-autocomplete>
<control-3>
<label>XML</label>
<hint/>
</control-3>
<section-1>
<label>Country Section</label>
</section-1>
</resource>
</resources>
</xf:instance>
<xf:instance id="get-default-country-value-instance" class="fr-service"
xxf:exclude-result-prefixes="#all">
<body xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:fbf="java:org.orbeon.oxf.fb.FormBuilder"><params/></body>
</xf:instance>
<xf:submission id="get-default-country-value-submission" class="fr-service"
resource="http://restcountries.eu/rest/v2/name/deutschland"
method="get"
serialization="none"
mediatype="none"/>
<xf:instance id="json-to-xml-instance" class="fr-service" xxf:exclude-result-prefixes="#all">
<body xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:fbf="java:org.orbeon.oxf.fb.FormBuilder"><params/></body>
</xf:instance>
<xf:submission id="json-to-xml-submission" class="fr-service"
resource="http://restcountries.eu/rest/v2/all"
method="get"
serialization="none"
mediatype="none"/>
<xf:action id="show-json-in-xml-binding">
<xf:action event="fr-run-form-load-action-after-controls" ev:observer="fr-form-model"
if="true()">
<xf:send submission="json-to-xml-submission"/>
</xf:action>
<xf:action event="xforms-submit" ev:observer="json-to-xml-submission">
<xf:var name="request-instance-name" value="'json-to-xml-instance'"/>
<xf:action/>
</xf:action>
<xf:action event="xforms-submit-done" ev:observer="json-to-xml-submission">
<xf:action class="fr-set-control-value-action">
<xf:var name="control-name" value="'control-3'"/>
<xf:var name="control-value" value="saxon:serialize(., 'xml')"/>
</xf:action>
</xf:action>
</xf:action>
<xf:action id="set-country-default-value-binding">
<xf:action event="DOMActivate" ev:observer="country-dynamic-autocomplete-control"
if="true()">
<xf:send submission="get-default-country-value-submission"/>
</xf:action>
<xf:action event="xforms-submit" ev:observer="get-default-country-value-submission">
<xf:var name="request-instance-name" value="'get-default-country-value-instance'"/>
<xf:action/>
</xf:action>
<xf:action event="xforms-submit-done" ev:observer="get-default-country-value-submission">
<xf:action class="fr-set-control-value-action">
<xf:var name="control-name" value="'country-dynamic-autocomplete'"/>
<xf:var name="control-value" value="saxon:serialize(., 'xml')"/>
</xf:action>
</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-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<fr:autocomplete xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
id="country-dynamic-autocomplete-control"
labelref="#label"
max-results-displayed="300"
resource="http://restcountries.eu/rest/v2/all"
bind="country-dynamic-autocomplete-bind">
<xf:label ref="$form-resources/country-dynamic-autocomplete/label"/>
<xf:hint ref="$form-resources/country-dynamic-autocomplete/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xf:itemset ref="/_/name">
<xf:label ref="name"/>
<xf:value ref="alpha2Code"/>
</xf:itemset>
</fr:autocomplete>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input id="control-3-control" bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>

Orbeon Forms: working with xxf:dynamic

I'm trying to add dynamic form with xxf:dynamic on Form Builder (ver. 4.9).
On "builder screen" I see input fields from dynamic instance, but when I want to test it by test button I don't see it at all.
Here is my code:
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<xh:head>
<xh:title>Untitled Form</xh:title>
<xf:model id="fr-form-model" xxf:expose-xpath-types="true">
<xf:instance id="dynamic-form">
<xh:html>
<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">
<form>
<section-1>
<control-1/>
<control-3/>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind id="fr-form-binds-nowy" ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-1-bind" name="control-1" ref="control-1"/>
<xf:bind id="control-3-bind" ref="control-3" name="control-3"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<section-1>
<label>Untitled Section</label>
</section-1>
<control-1>
<label>example 1</label>
<hint/>
<alert/>
</control-1>
<control-3>
<label>example 2</label>
<hint/>
</control-3>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xbl="http://www.w3.org/ns/xbl">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:input id="control-1-control" bind="control-1-bind">
<xf:label ref="$form-resources/control-1/label"/>
<xf:hint ref="$form-resources/control-1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td>
<xf:input id="control-3-control" bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
</xh:html>
</xf:instance>
<!-- Main instance -->
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<control-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="control-1-bind" name="control-1" ref="control-1"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata" xxf:exclude-result-prefixes="#all">
<metadata>
<application-name>test</application-name>
<form-name>dynamic_site</form-name>
<title xml:lang="en">Untitled Form</title>
<description xml:lang="en"/>
<singleton>false</singleton>
</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 -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false" xxf:exclude-result-prefixes="#all">
<resources>
<resource xml:lang="en">
<section-1>
<label>Untitled Section</label>
</section-1>
<control-1>
<label/>
<hint/>
<alert/>
</control-1>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<xxf:dynamic ref="instance('dynamic-form')"/>
<fr:body xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:xbl="http://www.w3.org/ns/xbl">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:input id="control-1-control" bind="control-1-bind">
<xf:label ref="$form-resources/control-1/label"/>
<xf:hint ref="$form-resources/control-1/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
<xh:td/>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
Unfortunately, the short answer is that <xxf:dynamic> is not documented and should really be considered an internal feature for the use of Form Builder only at this point.

How can I set the relevant property of an Orbeon element to depends on if a previous element is visited or not?

I am trying to create in a form some elements that are visible if one specific element has been visited or not. Is it possible?
At this moment, I only can achieve this copying the relevant part of the first element to the others one, but, in the case on one element depends on many others elements, the relevant rule is too large. Then I am looking for some way to simply this: is there any kind of function like "isVisible()"?
Something like (i.e. control-2 must be visible only if control-1 is visible):
<xf:bind id="control-2-bind" ref="control-2" name="control-2" relevant="isVisible($control-1)"/>
EDITED:
An example of form, where control-5 must be shown only if control-4 is shown.
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<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">
<form>
<section-1>
<control-3/>
<control-4/>
<control-5/>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" id="fr-form-binds"
ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-3-bind" ref="control-3" name="control-3"/>
<xf:bind id="control-4-bind" ref="control-4" name="control-4"
relevant="$control-3='one'"/>
<xf:bind id="control-5-bind" ref="control-5" name="control-5"
relevant="xxforms:visited($control-4)"/>
</xf:bind>
</xf:bind>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata">
<metadata>
<application-name>asd</application-name>
<form-name>asd</form-name>
<title xml:lang="en">Untitled Form</title>
<description xml:lang="en"/>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false">
<resources>
<resource xml:lang="en">
<control-3>
<item>
<label>First choice</label>
<value>one</value>
</item>
<item>
<label>Second choice</label>
<value>two</value>
</item>
<item>
<label>Third choice</label>
<value>three</value>
</item>
<label/>
<hint/>
</control-3>
<control-4>
<label>Input</label>
<hint/>
</control-4>
<control-5>
<label>Visited</label>
<hint/>
</control-5>
<section-1>
<label>Untitled Section</label>
</section-1>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:select1 id="control-3-control" appearance="full" bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xf:itemset ref="$form-resources/control-3/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input id="control-4-control" bind="control-4-bind">
<xf:label ref="$form-resources/control-4/label"/>
<xf:hint ref="$form-resources/control-4/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:output id="control-5-control" bind="control-5-bind">
<xf:label ref="$form-resources/control-5/label"/>
<xf:hint ref="$form-resources/control-5/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:output>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
The code is not working. The control-5 is never shown. What is wrong there?
EDITED: An example using the proposed solution "instance('visited')"
<xh:html xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:saxon="http://saxon.sf.net/"
xmlns:sql="http://orbeon.org/oxf/xml/sql"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:fb="http://orbeon.org/oxf/xml/form-builder">
<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">
<form>
<section-1>
<control-3/>
<control-4/>
<control-5/>
</section-1>
</form>
</xf:instance>
<!-- Bindings -->
<xf:bind xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel" id="fr-form-binds"
ref="instance('fr-form-instance')">
<xf:bind id="section-1-bind" name="section-1" ref="section-1">
<xf:bind id="control-3-bind" ref="control-3" name="control-3"/>
<xf:bind id="control-4-bind" ref="control-4" name="control-4"
relevant="$control-3='one'"/>
<xf:bind id="control-5-bind" ref="control-5" name="control-5"
relevant="instance('visited') = 'true' and string-length($control-4)>0"/>
</xf:bind>
</xf:bind>
<!-- Keep track of visited status -->
<xf:instance id="visited">
<visited/>
</xf:instance>
<xf:setvalue ev:event="xxforms-visited" observer="control-4-control"
ref="instance('visited')"
value="'true'"/>
<xf:setvalue ev:event="xxforms-unvisited" observer="control-4-control"
ref="instance('visited')"
value="'false'"/>
<!-- Metadata -->
<xf:instance xxf:readonly="true" id="fr-form-metadata">
<metadata>
<application-name>asd</application-name>
<form-name>asd</form-name>
<title xml:lang="en">Untitled Form</title>
<description xml:lang="en"/>
</metadata>
</xf:instance>
<!-- Attachments -->
<xf:instance id="fr-form-attachments">
<attachments>
<css mediatype="text/css" filename="" size=""/>
<pdf mediatype="application/pdf" filename="" size=""/>
</attachments>
</xf:instance>
<!-- All form resources -->
<!-- Don't make readonly by default in case a service modifies the resources -->
<xf:instance id="fr-form-resources" xxf:readonly="false">
<resources>
<resource xml:lang="en">
<control-3>
<item>
<label>First choice</label>
<value>one</value>
</item>
<item>
<label>Second choice</label>
<value>two</value>
</item>
<item>
<label>Third choice</label>
<value>three</value>
</item>
<label/>
<hint/>
</control-3>
<control-4>
<label>Input</label>
<hint/>
</control-4>
<control-5>
<label>Visited</label>
<hint/>
</control-5>
<section-1>
<label>Untitled Section</label>
</section-1>
</resource>
</resources>
</xf:instance>
<!-- Utility instances for services -->
<xf:instance id="fr-service-request-instance" xxf:exclude-result-prefixes="#all">
<request/>
</xf:instance>
<xf:instance id="fr-service-response-instance" xxf:exclude-result-prefixes="#all">
<response/>
</xf:instance>
</xf:model>
</xh:head>
<xh:body>
<fr:view>
<fr:body xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:oxf="http://www.orbeon.com/oxf/processors"
xmlns:p="http://www.orbeon.com/oxf/pipeline"
xmlns:dataModel="java:org.orbeon.oxf.fb.DataModel">
<fr:section id="section-1-control" bind="section-1-bind">
<xf:label ref="$form-resources/section-1/label"/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:select1 id="control-3-control" appearance="full" bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xf:itemset ref="$form-resources/control-3/item">
<xf:label ref="label"/>
<xf:value ref="value"/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:input id="control-4-control" bind="control-4-bind">
<xf:label ref="$form-resources/control-4/label"/>
<xf:hint ref="$form-resources/control-4/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
</xh:td>
</xh:tr>
<xh:tr>
<xh:td>
<xf:output id="control-5-control" bind="control-5-bind">
<xf:label ref="$form-resources/control-5/label"/>
<xf:hint ref="$form-resources/control-5/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:output>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
</fr:body>
</fr:view>
</xh:body>
In this example, if you select 'First Choice' then, the Input Field is shown. And if you fill it with any value, 'Visited' label is therefore shown. This is the expected behaviour. But, if you later change the Radio Button to 'Second Choice', the Input Field is hidden but the 'Visited' label is still visible (only will be hidden if the user deletes the value of the input field, but now is hidden). This is undesired. There is any way to avoid this?
NOTE: I have added string-length() to be sure that is hidden if the value has been removed. Without it, always is visible.
Since Orbeon Forms 4 there is:
the xxf:visited() function
the xxforms-visited and xxforms-unvisited events
You have to be careful with dependencies when using the function, especially on xf:bind.
I tried to build a naive example, but it turns out that it doesn't work and I entered an issue.
Here is a workaround, which requires adding a custom XForms instance:
<xf:bind id="control-5-bind" ref="control-5" name="control-5"
relevant="instance('visited') = 'true'"/>
<xf:instance id="visited"><visited/></xf:instance>
<xf:setvalue event="xxforms-visited" observer="control-4-control" ref="instance('visited')" value="'true'"/>
<xf:setvalue event="xxforms-unvisited" observer="control-4-control" ref="instance('visited')" value="'false'"/>
And here is the complete example.

Resources