• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple Question about bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Question about bindings


  • Subject: Re: Simple Question about bindings
  • From: John Huss <email@hidden>
  • Date: Wed, 26 Aug 2009 14:13:52 -0500

Yeah, what you want is:

value = email@hiddenPrice;

John

On Wed, Aug 26, 2009 at 1:48 PM, Michael Shkutkov <email@hidden> wrote:
I guess, the cause of this problem is the fact that NSArray implements NSKeyValueCoding interface and has valueForKey method.

Obviously extending NSMutableArray is really bad idea...


On Wed, Aug 26, 2009 at 9:20 PM, Francesco Romano <email@hidden> wrote:
Hi..
This is a very simple question, and I was able to find a workaround.. but I'd like to know where is the problem...

I've this class:

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);
}

}

All my order classes inherit from that class. (this only to have the order object without rewriting it every time..).

If I have this binding:

CartSubtotal: WOString {
value = order.cart.cartTotal;
numberformat = "$#0.00";
}
When I render the page I get this exception:

valueForKey(): lookup of unknown key: 'cartTotal'. This class does not have an instance variable of the name cartTotal or _cartTotal, nor a method of the name cartTotal, _cartTotal, getCartTotal, or _getCartTotal' object 'com.portonapoleone.store.utils.CartItem@eac903' key 'cartTotal'>

If I change the binding to this I have no problem:

CartSubtotal: WOString {
value = cartTotal;
numberformat = "$#0.00";
}

public double cartTotal() {
return order().cart().cartTotal();
}

These are the other classes involved:

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;
}

}

Francesco




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



--
Cheers, Michael

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Simple Question about bindings
      • From: John Huss <email@hidden>
References: 
 >Simple Question about bindings (From: Francesco Romano <email@hidden>)
 >Re: Simple Question about bindings (From: Michael Shkutkov <email@hidden>)

  • Prev by Date: Re: Simple Question about bindings
  • Next by Date: Re: Simple Question about bindings
  • Previous by thread: Re: Simple Question about bindings
  • Next by thread: Re: Simple Question about bindings
  • Index(es):
    • Date
    • Thread