This is a very simple question, and I was able to find a workaround.. but I'd like to know where is the problem...
public class OrderComponent extends ERXComponent {
private TemporaryOrder order;
public OrderComponent(WOContext context) {
super(context);
}
public void setOrder(TemporaryOrder order) {
this.order = order;
}
public TemporaryOrder order() {
return order;
}
@Override
public void awake() {
super.awake();
setOrder(null);
}
}
public class TemporaryOrder {
private CartArray cart;
private String shipmentAddress;
public TemporaryOrder(CartArray c) {
cart = c;
}
public CartArray cart() {
return cart;
}
public void setShipmentAddress(String shipmentAddress) {
this.shipmentAddress = shipmentAddress;
}
public String shipmentAddress() {
return shipmentAddress;
}
}
public class CartArray extends NSMutableArray<CartItem> {
public boolean add(Prodotto p) {
return add(p,1);
}
public boolean add(Prodotto p, int i) {
CartItem ci = new CartItem(p);
if (contains(ci)) {
CartItem oldCI = objectAtIndex(indexOf(ci));
oldCI.quantity += i;
return true;
}
else {
ci.quantity = i;
return super.add(ci);
}
}
public double cartTotal() {
double total = 0;
Iterator<CartItem> it = this.iterator();
CartItem ci = null;
while (it.hasNext()) {
ci = it.next();
total += ci.totalPrice();
}
return total;
}
}