Autocomplete in QAFE using the 'suggest' attributePublished on: Author: Mellisa Michely-Kartowikromo Category: IT development and operations
Here is a quick follow up on the QAFE introduction post by Karizma. About a neat feature: autocomplete.
In QAFE there is a very simple option to apply autocomplete for a textfield. Autocomplete is a feature that automatically predicts the remaining letters in a word based on what has been typed before.
How is this done?
In the textfield set the suggest attribute to 'true'. With the 'suggest-chars' attribute you can define the minimum amount of letters before the suggestion list appears.
- <textfield id="autocompleteId" name="autocompleteName" type="text" width="240" suggest="true" suggest-chars="3" />
The next step is to write the bussiness-action and the event to make it work. This textfield needs to listen to the 'onchange' listener type.
- <component ref="autocompleteId" />
- <listener type="onchange" />
- <store name="storeAutoCompl" src="component" ref="autocompleteId" />
- <business-action ref="autocompleteStreetBusinessAction">
- <in name="streetName" ref="storeAutoCompl" />
- <out name="suggestionList" ref="suggestionList" />
- <set component-id="autocompleteId" ref="suggestionList">
- <mapping key="id" value="streetId" />
- <mapping key="value" value="streetName" />
When you type a minimum of 3 letters in the textfield, the bussiness-action gives you a list of streetnames as output (in this case the suggestionList). This list contains a streetId and streetName for every record.
To make sure the suggestion list appears you need to set the results for the textfield. This is done by using the 'set' option. In the 'component-id' attribute you need to fill in the textfield id and the 'ref' is referencing to the output list generated by the bussiness-action.
The last thing you need to do is the mapping, which you can see in the example.
I hope this post will be helpful to other QAFE users out there.