Autocomplete configuration in resource mode

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

Autocomplete configuration in resource mode

fbonin
Hi,
I have 2 questions

1) Is it possible to configure the delay before a web service call is done when using the autocomplete field ?

2) Is it possible to configure the minimum number of characters necessary because a web service call is done ? I only found a way to do it in dynamic mode but I was wondering if it is also possible to do in resource mode (http://doc.orbeon.com/form-runner/component/autocomplete.html)

Thank you !
Reply | Threaded
Open this post in threaded view
|

Re: Autocomplete configuration in resource mode

Alessandro  Vernet
Administrator
Hi Frederic,

If you're writing XForms by hand, and use it in the "dynamic mode", you get an event fr-search-changed when the search text has changed, and you can control whether to call the service or not. It's very easy in that situation not call the service of the "search text" is too short, and in fact there is even an example of this in the documentation:

http://doc.orbeon.com/form-runner/component/autocomplete.html#dynamic

Similarly, leveraging delayed events, you could write some logic in XForms so you're not calling your service before a certain time has elapsed.

In resource mode, which is what you get if building the form with Form Builder, you could simulate your length requirement by writing a resource URL that looks like:

?country-name={if (string-length($fr-search-value) < 5) then '' else $fr-search-value}

So in effect, your service won't get called with strings of less than 5 characters.

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