appending to autoComplete

UI Components for JSF
Post Reply
vijayprimefaces
Posts: 25
Joined: 15 Aug 2011, 19:39

16 Dec 2011, 06:33

Hello,

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 :

Code: Select all

      <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

Lyrionus
Posts: 60
Joined: 31 Aug 2011, 09:09

16 Dec 2011, 10:28

Well, what you can do is keep a variable on your controller that, every time you select something different your select handler will take the old value and add it to your list in the complete method.
JSF 2.0
Primefaces 3.2
Tomcat 7.0

vijayprimefaces
Posts: 25
Joined: 15 Aug 2011, 19:39

16 Dec 2011, 10:33

Lyrionus wrote:Well, what you can do is keep a variable on your controller that, every time you select something different your select handler will take the old value and add it to your list in the complete method.
Which list are you referring to?

I have value field in the autoComplete which is a POJO for emails(lastname, emails).

I have another ouputText in the form which does exactly what u said. I keep appending it with the value selected from autoComplete (with select handler). Whereas I want all the values in the autoComplete field itself.

Just to make it clear it should work exactly as the To: field of outlook or gmail. You type a name help appears and the selected name gets added to previous text.

Thanks for your help

Lyrionus
Posts: 60
Joined: 31 Aug 2011, 09:09

16 Dec 2011, 11:19

Well, if you have the outputText that does what i suggested, can't you just add that to a list aswell? And keep adding items to it? Then when your autocompleter method fires and gives you back a list you add the list you saved to it aswell?
JSF 2.0
Primefaces 3.2
Tomcat 7.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests