I have tried this on Orbeon 4.6 and 4.7.
ORBEON.xforms.Document.setValue, getValue or DispatchEvents commands throw error dialogs when called.
Appreciate if someone has had any luck in getting these to work.
Please see a snipet below of the xhtml, when I run this the alert message displays "undefined" when it should have displayed "42", if I change the getValue() to setValue() and pass the name and value as parameters the system returns an error :
<xf:instance id="fr-form-instance" xxf:exclude-result-prefixes="#all">
<form>
<section-1>
<control-1/>
<foo>42</foo>
<bar/>
</section-1>
</form>
</xf:instance>
.......
<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>
<xf:input ref="foo" id="foo">
<xf:label class="fixed-width">Value of foo:</xf:label>
</xf:input>
<xf:output ref="bar">
<xf:label class="fixed-width">Value of bar:</xf:label>
</xf:output>
<xf:trigger>
<xf:label>JavaScript</xf:label>
<xxf:script ev:event="DOMActivate">
alert(ORBEON.xforms.Document.getValue("foo"));
</xxf:script>
</xf:trigger>
</xh:td>
It isn't working because you need to use the id as it is in the HTML, and the id in the HTML is different from the control name in 2 ways:
-control
at the end of the name to produce the id.Because of this, if your control is named my-control
in Form Builder, I'd recommend you use the following to get its value in JavaScript:
var control = ORBEON.jQuery('*[id $= "my-control-control"]');
var value = ORBEON.xforms.Document.getValue(control.attr('id'));