I am trying to change a validation constraint alert by concatenating a request value but at this moment I have not found the key.
I have followed this example: http://discuss.orbeon.com/Changing-section-s-label-dynamically-td4661767.html
My control is like this:
<fr:c x="9" y="1" w="2" h="1">
<xf:input id="my-field-control"
bind="my-field-bind"
class="my-field">
<xf:label ref="$form-resources/my-field/label"/>
<xf:hint ref="$form-resources/my-field/hint"/>
<xf:alert ref="$form-resources/my-field/alert[1]"
validation="validation-82-validation"/>
<xf:alert ref="$form-resources/my-field/alert[2]"
validation="validation-61-validation"/>
<xf:alert ref="$form-resources/my-field/alert[3]"
validation="validation-79-validation"/>
<xf:alert ref="$form-resources/my-field/alert[4]"
validation="validation-80-validation"/>
<xf:alert ref="$form-resources/my-field/alert[5]"
validation="validation-81-validation"/>
<xf:alert ref="$form-resources/my-field/alert[6]"/>
<xf:action ev:event="xforms-ready">
<xf:setvalue ref="instance('fr-form-resources')/resources/resource[@xml:lang = 'es']/my-field/alert[1]"
value="concat(instance('fr-form-resources')/resources/resource[@xml:lang = 'es']/my-field/alert[1],xxf:get-request-parameter('my-request-parameter'))"/>
<xf:setvalue ref="instance('fr-form-resources')/resources/resource[@xml:lang = 'ca']/my-field/alert[1]"
value="concat(instance('fr-form-resources')/resources/resource[@xml:lang = 'ca']/my-field/alert[1],xxf:get-request-parameter('my-request-parameter'))"/>
</xf:action>
</xf:input>
</fr:c>
<xf:instance id=""fr-form-resources"" xxf:readonly=""false"" xxf:exclude-result-prefixes=""#all"">
<resources>
<resource xml:lang=""es"">
<my-field>
<label>my field</label>
<hint/>
<alert>Message</alert>
<alert>Message</alert>
<alert>Message</alert>
<alert>Message</alert>
<alert>Alert to change programatically</alert>
<alert/>
</my-field>
</resource>
<resource xml:lang=""ca"">
<my-field>
<label>my field</label>
<hint/>
<alert>Message</alert>
<alert>Message</alert>
<alert>Message</alert>
<alert>Message</alert>
<alert>Alert to change programatically</alert>
<alert/>
</my-field>
</resource>
</resources>
</xf:instance>
When I change the value of the field, constraints are launched and request parameter is present because is used to check the constraint which its label I want to change but the validation message is always 'Alert to change programatically'
not 'Alert to change programatically + my-request-parameter value'
.
Your approach of reacting to the xforms-ready
event to update the instance with the resources makes sense. However, to run, your handler needs to be inside the <xf:model>
, as xforms-ready
is an event dispatched to models.
To debug this, you can also insert <xf:message value="…">
in your action, to check that code runs, and to check that certain expressions indeed return the value you expect.