protected void setup ( SuggestOracle suggestions ) { if ( itemBoxKeyDownHandler != null ) { itemBoxKeyDownHandler . removeHandler ( ) ; } list . setStyleName ( AddinsCssName . MULTIVALUESUGGESTBOX_LIST ) ; this . suggestions = suggestions ; final ListItem item = new ListItem ( ) ; item . setStyleName ( AddinsCssName . MULTIVALUESUGGESTBOX_INPUT_TOKEN ) ; suggestBox = new SuggestBox ( suggestions , itemBox ) ; suggestBox . addSelectionHandler ( selectionEvent -> { Suggestion selectedItem = selectionEvent . getSelectedItem ( ) ; itemBox . setValue ( "" ) ; if ( addItem ( selectedItem ) ) { ValueChangeEvent . fire ( MaterialAutoComplete . this , getValue ( ) ) ; } itemBox . setFocus ( true ) ; } ) ; loadHandlers ( ) ; setLimit ( this . limit ) ; String autocompleteId = DOM . createUniqueId ( ) ; itemBox . getElement ( ) . setId ( autocompleteId ) ; item . add ( suggestBox ) ; item . add ( label ) ; list . add ( item ) ; panel . add ( list ) ; panel . getElement ( ) . setAttribute ( "onclick" , "document.getElementById('" + autocompleteId + "').focus()" ) ; panel . add ( errorLabel ) ; suggestBox . setFocus ( true ) ; }
Generate and build the List Items to be set on Auto Complete box .