I'm stuck with the following problem in my JSF application : I've got a page containing several forms, each formed with two commandButton and an ajax tag. I want to perform the method addArticleToCart when the user click on the second button , but I also want to set in a backing bean a property (qty) to get this value available for my addArticle method. The problem is that when I'm not using ajax tag, the qty value is set to the last inputtext value (not the clicked one). When I'm using ajax, the first click on the page is working but then : - if I click on another form button the first click is not working (the second, third ... are working) ... - If I click on the same form it's working ...
So I'm asking, is it possible to do what I need without ajax ? Because it's driving me crazy , and when I'm removing the render attribute from ajax tag , the method is called but the price (of the cart) is not updated , I must perform a refresh ... Thanks in advance for your help
<composite:implementation>
<li class="span2 thumbnail">
<h:form id="cocktailThumbnail">
<div class="filling-thumb">
<ui:param name="img_path" value="img:#{cc.attrs.item.photoURIName}.#{cc.attrs.item.photoURIExt}" />
<img src="#{resource[img_path]}" alt="Cocktail#{cc.attrs.item.name}"/>
</div>
<div class="caption">
<h3 class="title-cocktail">#{cc.attrs.item.name}</h3>
<div class="text-center">
<div class="btn-group" >
<h:commandButton image="#{resource['img:info_small.png']}"
alt="Détails du cocktail"
title="#{dataManagedBean.getCocktail(cc.attrs.item.ID).getRecipe()}"
styleClass="btn"
action="#{dataManagedBean.displayCocktailDetails(cc.attrs.item)}">
</h:commandButton>
</div>
<br/><br/>
<div class="input-prepend">
<h:commandButton image="#{resource['img:cart_small.png']}"
alt="Ajouter le cocktail au panier"
title="Ajouter le cocktail au panier"
styleClass="btn"
actionListener="#{dataManagedBean.addArticleToCart(cc.attrs.item)}">
<!--Utilisation de ajax sinon lors du clic tous les input sont envoyé et donc qty = qty du dernier input
Avec ajax on envoie que ce form et it works -->
<f:ajax execute="@this" render="@all" />
</h:commandButton>
<h:inputText alt="Nombre de cocktails à ajouter au panier"
maxlength="3"
value="#{dataManagedBean.qty}"
styleClass="input-mini"
title="Nombre de cocktails à ajouter au panier" />
</div>
</div>
</div>
</h:form>
</li>
</composite:implementation
EDIT : When I'm changing the render with render=":menubar" everything is working fine and it does what I want ... Do you have an explanation ?