I am using JSF 2.0, PF M3 and GF 3.1.
I have a autocomplete control in my email form. As soon as I select from the drop down suggestions provided by autocomplete control, it replaces the old value in the control. How can I make it work so that each time a new selection is made the selected text is appended to the previously selected text.
My view file is :
<p:autoComplete id="emailForm"
value="#{mail.emailTo}"
required="true"
completeMethod="#{myController.complete}"
var="p"
itemLabel="#{p.lastName} <#{p.email}>"
itemValue="#{p}"
size="60">
<p:ajax event="itemSelect" listener="#{myController.handleSelect}"/>
</p:autoComplete>
All the help is appreciated.
Thanks
What do you mean exactly by
selected text is appended to the previously selected text?If I understand correctly, this is not a good practice: means that your
complete method(myController.complete) has a wrong implementation. You could revise your code…Anyway, you could append the entered keys(text) with the one selected as a suggestion by appending the value
mail.emailTowith the result returned from DB, handled bymyController.completemethod.Update:
Firstly you should consider upgrade to RC1, and then read the manual ( http://www.primefaces.org/documentation.html ), so you can understand the differences between simple autocomplete and autocomplete with pojo support;
You will use pojo support when working with your own objects(and not just lists), also you will use itemLabel and itemValue in the same case. When working with pojo you get the converting error because you have to implement your own converter. If all these things are strange to you, then use the simple autocomplete and you’ll be fine!
Consider reading all those links I’ve provided to you for a better understanding of Primefaces components in general (autocomplete in particular)