Play with Lift’s Autocomplete Widget using Scala-One of the Best Feature of LiftWeb Framework

Table of contents
Reading Time: 3 minutes

The AutoComplete widget provides a flexible and accessible way to offer suggestions or some kind of filtering information as a user type text information in an input field . If you have used Google , you might see that Google starts providing autocomplete suggestion with entries depending on user’s current input .

Lift provides a very easy way to implement Autocomplete using Scala .

Here , I am going to explain two ways to implement Autocomplete Functionality in Lift using Scala .

1) Using this way , you can use Lift’s Autocomplete widget but with limited features .

Simple Autocomplete

Here is how we integrate it into your Lift application.

a)Initialisation

Add below line in Boot.Scala

b) Snippet Binding
In order to implement in Snippet , follow below lines :-

2) If you have used Facebook , you might agree that at many places , Facebook provides filtered information in a very nice way . Using above way , you could not implement like this .
For this you have to extend Autocomplete.Scala and modify it . In one of my project , I implemented Auto complete widget in facebook style by modifying Autocomplete.Scala .

Customized Autocomplete Widget

In the Snippet :

In the above code , getResults is returning sequence of 5 strings . I have modified Autocomplete.Scala as per requirement . You can modified this file , if you want to make your Autocomplete widget to be more attractive .

Lift’s Auto complete Widget is basically a JQuery’s AutoComplete widget . You can use Jquery’s Autocomplete property in Autocomplete.Scala .

Written by 

Ayush is the Sr. Lead Consultant @ Knoldus Software LLP. In his 10 years of experience he has become a developer with proven experience in architecting and developing web applications. Ayush has a Masters in Computer Application from U.P. Technical University, Ayush is a strong-willed and self-motivated professional who takes deep care in adhering to quality norms within projects. He is capable of managing challenging projects with remarkable deadline sensitivity without compromising code quality.

2 thoughts on “Play with Lift’s Autocomplete Widget using Scala-One of the Best Feature of LiftWeb Framework5 min read

Comments are closed.