diff --git a/src/main/java/de/hsel/itech/jsf/CartBean.java b/src/main/java/de/hsel/itech/jsf/CartBean.java index bfdc511..eaee783 100644 --- a/src/main/java/de/hsel/itech/jsf/CartBean.java +++ b/src/main/java/de/hsel/itech/jsf/CartBean.java @@ -8,6 +8,7 @@ import javax.faces.annotation.ManagedProperty; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; +import javax.faces.event.ValueChangeEvent; import java.sql.Date; import java.util.ArrayList; import java.util.List; @@ -35,6 +36,9 @@ public class CartBean { return (Address) context.getApplication().evaluateExpressionGet(context, "#{addressBean.selected}", Address.class); } + @Setter + private List items; + public String add(Book book) { if (getUser() != null && getUser().getId() != 0) { for (ShoppingCartItem item : getItems()) { @@ -58,11 +62,20 @@ public class CartBean { } public List getItems() { + if(items != null) return items; Database db = Database.getInstance(); if (getUser() != null) { - return db.shoppingCart().get(getUser()); + items = db.shoppingCart().get(getUser()); } else { - return new ArrayList(); + items = new ArrayList(); + } + return items; + } + + public void change(ValueChangeEvent event) { + System.out.println("änderung"); + for(ShoppingCartItem item : getItems()) { + System.out.println(item.getCount()); } } diff --git a/src/main/webapp/cart.xhtml b/src/main/webapp/cart.xhtml index 64e4aaf..f06bbd2 100644 --- a/src/main/webapp/cart.xhtml +++ b/src/main/webapp/cart.xhtml @@ -38,7 +38,14 @@
- + + + + + + + +