command buttons inside Auto complete suggestions

Components, Ajax Framework, Utilities and More.
Post Reply
vi_mahe_ka1
Posts: 5
Joined: 06 May 2013, 15:18

24 Jan 2014, 11:20

Hi
I am working for an e commerce project and trying to achieve below scenario using Autocomplete component.
Scenario: when user searchs, search results will appear in auto complete suggestions along with add button, clicking on that will add it to cart. I am able to populate the results however clicking on button is not triggering any action but instead it is selecting the item.
can anybody help in achieving this?
Code:

Code: Select all

<p:autoComplete value="#{searchManagedBean.selectedItem}"
						minQueryLength="3" queryDelay="300" id="searchPojo" 
						completeMethod="#{searchManagedBean.search}" scrollHeight="300"
						var="item" itemLabel="#{item.name}" itemValue="#{item}"
						converter="item" forceSelection="true">
<p:column>
							
							<p:commandButton title="Add" icon="cart-basket"
								action="#{searchManagedBean.addToCart}"
								styleClass="ui-button cart-button">
								</p:commandButton>
						</p:column></p:autoComplete>
Primefaces 3.5.8
JSF 2
Tomcat 6
PrimeFaces 4.0 Tomcat 6 | Mojarra 2.1.11

User avatar
andyba
Expert Member
Posts: 2475
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

24 Jan 2014, 15:29

You don't need the button, you can add the selected item to your cart in the complete method.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

salviof
Posts: 7
Joined: 14 Aug 2013, 08:26

18 May 2017, 15:40

I need to display many dynamic buttons on autocomplete , thats not working..

-> using composite component mojarra 2.3 and Prime 6.1.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider], Google [Bot] and 4 guests