0

I'm working on custom control in Orbeon. In form builder, in settings there is a field called buttonName. Its value is supposed to show as a label of button visible in form runner.

I'm moving an old file that supposedly worked on old version of orbeon. I tried changing the way I refer to the value from form builder. Below I show old code, without my changes.

In form builder metadata I have declared input with ref:

<xbl:binding element="fr|custom-input" id="fr-custom-input-binding" xxbl:mode="lhha binding value">
        <!-- Orbeon Form Builder Component Metadata -->
        <metadata xmlns="http://orbeon.org/oxf/xml/form-builder" xmlns:xf="http://www.w3.org/2002/xforms">
...
<control-details>
<xf:input ref="@buttonName">
                    ...

Further on, there is a var to that binding

<xf:var name="binding" value="xxf:binding('fr-custom-input-binding')"/>

Finally, the reference in form runner:

                <xf:trigger class="xbl-fr-custom-input-trigger">
...
                    <xf:label value="$binding/@buttonName"></xf:label>
                </xf:trigger>
MiKk
  • 1
  • And what is the issue? Are you saying that the input field you defined in `` doesn't show up anymore on the Control Details in new versions of Orbeon Forms? If so, what version of Orbeon Forms are you referring to? – avernet May 13 '19 at 17:06
  • No, no, the input field in control details shows and works correctly. What I'm trying to do is to get value from that field and show it as label of button in the view. – MiKk May 14 '19 at 07:39
  • OK, so your input shows in the Control Details dialog. When you enter a value there, and hit save, is it saved in the `buttonName` attribute on the `` in the source of your form? If not, is the attribute even there, even if empty? I suspect this isn't working for you because of [#4030](https://github.com/orbeon/orbeon-forms/issues/4030), which is fixed and will be in Orbeon Forms PE 2018.2.3 or Orbeon Forms CE 2019.1. Are you using Orbeon Forms CE or PE? – avernet May 14 '19 at 22:42
  • Yes, the value is saved in attribute of the input. I'm using Orbeon Forms CE. – MiKk May 15 '19 at 09:18
  • OK, so you end up with `` in the source of the form. That's good. Then I would have guessed that using `$binding/@buttonName` in your XBL component would have worked. Can you try putting in the source of the component ``, check you see "gaga", if that works, replace `'gaga'` with `exists($binding)`, if that returns true, replace it with `exists($binding/@buttonName)`, if that returns true, replace it with `$binding/@buttonName`. Let's see if we can this way figure out where it fails. – avernet May 15 '19 at 21:21
  • ```exists($binding/@buttonName)``` returns false – MiKk May 16 '19 at 08:03
  • Ah… my bad: you attribute is on the control itself, ``, not the element to which the control is bound, which is what `$binding` points to. So `$binding/@buttonName` is not the right expression to use here. So instead, what you want to have inside your `` a ``. Then you can refer in XPath to the value of the attribute as `$buttonName`. You'll let me know if this works for you. – avernet May 17 '19 at 00:35
  • Hi MiKk, thank you for the confirmation, and I've posted a slightly expanded version of my above comment as an answer below, so people potentially finding this thread through a search don't have to read all out comments here. ‑Alex – avernet May 30 '19 at 06:38

1 Answers1

0

You want to access an attribute on the control itself:

<fr:custom-input buttonName="Your value">

This in contract to an attribute that you could have on the element the control is bound to, which is what $binding points to. So $binding/@buttonName is not the right expression to use here. Instead, inside your , you want to have:

<xf:var name="buttonName" xbl:attr="xbl:text=buttonName"/>

Then you can refer in XPath to the value of the attribute as $buttonName.

avernet
  • 30,895
  • 44
  • 126
  • 163