I have some problems with my JSF page which displays a list of pizzas. I go through each entry of my ArrayList which holds the pizza data with the ui:repeat loop. For each pizza the user can choose the size and the quantity before the user can add the pizza into the cart by clicking on a button. This is where the error occurs. By clicking the button, the JSF page refreshes and it happens nothing. There is no output on my console..
JSF-page code snippet:
<ui:repeat var="result" value="#{pizzaSearchBean.resultList}">
<h:form>
<ul>
<li><p>Name: #{result.pizza.name}</p></li>
<li><p>ID: #{result.pizza.pizzaID}</p></li>
<li>
<p>Toppings:</p>
<ui:repeat var="topping" value="#{result.toppingList}">
<p>#{topping.toppingName}</p>
</ui:repeat>
</li>
<li>
<p>Sizes:</p>
<h:selectOneRadio id="pizzasize" value="#{pizzaSearchBean.pizzasize}">
<f:selectItems value="#{result.sizeList} var="size" itemLabel="#{size.diameter}" itemValue="#{size.sizeID}"/>
</h:selectOneRadio>
</li>
<li>
<p>Quantity:</p>
<h:selectOneListbox id="pizzaquantity" value="#{pizzaSearchBean.pizzaquantity}" size="1">
<f:selectItem id="quantity1" itemLabel="1x" itemValue="1">
<f:selectItem id="quantity2" itemLabel="2x" itemValue="2">
</h:selectOneListbox>
</li>
<li>
<!-- this is where no action happens... -->
<h:commandButton value="add to cart" action="#{pizzaSearchBean.addToCart(result.pizza.pizzaID)}"/>
</li>
</ul>
</h:form>
</ui:repeat>
In the managedBean class there are several classes to manage all the data. The addToCard method looks just as simple as this:
public void addToCart(int pizzaid) {
System.out.println("pizza ID : " + pizzaid);
}
Everything works instead of the commandButton action method "addToCart()". No matter what is written inside the action tag of commandButton. After rendering the pizza search and clicking onto one of the pizza's "add to cart"-button there still will be no action..
I hope you can help me.. Thanks!