When I hit the commandButton it puts in the value that product.amount started as rather than what is currently typed in the input box.
<h:inputText value="#{product.amount}" />
<h:commandButton id="Button"
value="Buy"
tabindex="2" >
<f:ajax listener="#{shopBean.addToCart(product.product, product.amount)}"
execute="@this"
render="@all" />
</h:commandButton>
You need to include the input field in the
executeattribute of the<f:ajax>so that it get processed as well, otherwise it will simply be ignored altogether.Or just put the whole in a single form and use
execute="@form".By the way, the
render="@all"defeats one of the main advantages of using ajax. Try to render exactly only the component(s) which actually needs to be updated.