I have two inputs.
I want the two inputs to have the same look and feel see below:
The first input use autocomplete and allows the user to select a list of terms => I use p:autocomplete (see Primefaces documentation on autocomplete) This input works fine.
For the second input, I would like to have the same display but without any autocompletion : the user just enter a list of terms with no autocompletion at all. I tried to have a fake autocomplete that return the value given by the user but it is too slow and the behaviour is not correct when the user quit the input.
Any idea is welcome.
After a quick look at the PrimeFaces javascript code of the autoComplete and a few hours experimenting with it, I came up with a solution. It involves overriding the bindKeyEvents and in it deciding to call the original one or not, adding detection for the space key ('selecting a tag') and when pressed, add the tag and fire the selectionEvent (if ajax is used). Place the following code in your page or in an external javascript file
For deciding on when to call the original one or not, I decided to use a passThrough attribute with a
data-justTags
name. e.g.pt:data-justTags="true"
(value does not matter, sopt:data-justTags="false"
is identical topt:data-justTags="true"
). A small html snippet of this is:And do not forget to add the
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
namespace declaration.I found a component that could do the job : http://www.butterfaces.org/tags.jsf