Documentation
Project Documentation
Foundation

Description

A tag that defines an autosuggest control complete with Ajax binding.
This allows you to do real time autocompletion via asynchronous server requests. Note, this control is experimental and it is currently located in the MyFaces sandbox and can be subject to alteration in the immediate future. So use it with care.

Screen Shot

InputSuggestAjax

API

component-family javax.faces.Input
renderer-type org.apache.myfaces.InputSuggestAjax
component-class org.apache.myfaces.custom.inputsuggestAjax.InputSuggestAjax
renderer-class org.apache.myfaces.custom.inputsuggestAjax.InputSuggestAjaxRenderer
tag-class org.apache.myfaces.custom.inputsuggestAjax.InputSuggestAjaxTag

Syntax

<s:inputSuggestAjax id="id" binding="control binding"
                            suggestedItemsMethod="backend bean callback method" value="Bean"/>
            

Instructions

id - defines the id of the control
suggestedItemsMethod - defines the method call for the backend bean which delivers the preview data
maxSuggestedItems - defines the number of maximal suggested entries (optional)
value - standard bean value for the result
binding - the binding into a control object, this binding is needed because the control object does all the needed data transformation between the Ajax control and the backend/frontend

Note - This component is different to others, it uses Ajax mechanisms to fetch preview data from the server, thus the backend binding can and will be used outside of the standard JSF lifecycle to deliver the data.

Description of the call order:
control -> Ajax request -> suggestionMethod in backend bean -> values pushed into the control binding -> result sent back to the client -> control shows suggestion drop down

On the backend side, a callback method - the suggestion method, has to be implemented, which is called by the Ajax request and fetches the data from a data source. The data then is pushed into the control binding similarly to drop down menus and other controls which use the SelectItem object as data holder. The rest is done automatically.