Autocomplete: struggling with labelref

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Autocomplete: struggling with labelref

Heinrich Götzger
Hoi,

I'd like to use the labelref-feature with the autocomplete component.
But for some reason this is not working as expected.

Using orbeon 2016.2 CE or orbeon 4.5.0 CE it's still the same behavior,
There is no label stored in the labelref-instance.

What's wrong with the following (simplified) example:

<xh:html
    xmlns:xf="http://www.w3.org/2002/xforms"
    xmlns:xh="http://www.w3.org/1999/xhtml"
    xmlns:fr="http://orbeon.org/oxf/xml/form-runner">

    <xh:head>
       <xh:title>Autocomplete - Example</xh:title>
       <xf:model id="ac-model">

          <xf:instance id="country">
             <response>
                <country/>
                <countryName/>
             </response>
          </xf:instance>

          <xf:instance id="all-countries">
             <countries>
                <country>
                   <name>Austria</name>
                   <us-code>au</us-code>
                </country>
                <country>
                   <name>Germany</name>
                   <us-code>gm</us-code>
                </country>
                <country>
                   <name>Switzerland</name>
                   <us-code>sz</us-code>
                </country>
                <country>
                   <name>European Union</name>
                   <us-code>ee</us-code>
                </country>
             </countries>
          </xf:instance>

       </xf:model>

    </xh:head>

    <xh:body>

       <fr:autocomplete
          ref="instance('country')/country"
          labelref="instance('country')/countryName"
          dynamic-itemset="false"
          class="country-selection">
          <xf:label>Search country</xf:label>
          <xf:itemset ref="instance('all-countries')/country">
             <xf:value ref="us-code"/>
             <xf:label ref="name"/>
          </xf:itemset>
       </fr:autocomplete>

       <xf:output ref="country">
          <xf:label>Country: </xf:label>
       </xf:output>

       <xf:output ref="countryName">
          <xf:label>Country Name: </xf:label>
       </xf:output>

    </xh:body>

</xh:html>

--
Before printing this e-mail, think about our environmental responsibility.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Autocomplete: struggling with labelref

Alessandro  Vernet
Administrator
Hi Heinrich,

Simple: `labelref` is only supported in resource and dynamic mode, not in static mode. The idea being that in static mode you generally don't need to store the label since you have the full instance available right there. However, in resource or dyanmic mode, you *need* to store the label, as you typically can't get the label from the value, only the other way around, as the service you call typically uses the label for search.

If you're in static mode, either don't store the label (for sure it isn't needed by the autocomplete itself in static mode), or if you need it for some other reason, do it with an <xf:bind calculate="…">. Would that work for you?

And BTW, this is a control which would benefit from a refresh! :)

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Loading...