Help! valueForKey does not follow relationships?
Help! valueForKey does not follow relationships?
- Subject: Help! valueForKey does not follow relationships?
- From: Scott Ellsworth <email@hidden>
- Date: Fri, 11 Apr 2003 14:46:31 -0700
Hi, all.
Does valueForKey or storedValueForKey on an EOEnterpriseObject follow
toMany relationships?
I have created a custom component in the d2w sample app for Listings.
It is supposed to show only the lastName attributes of the targets of
the suggestedCustomers relationship.
There are values at the other end of that relationship, seen if I do
not use my custom component. I know getCombinedValue, which uses
storedValueForKey is getting called, because I see log entries. If
getCombinedValue is hardcoded to return "tickytack", it shows up in the
component, so the binding is working.
In short, calling object.valueForKey("suggestedCustomers") returns an
empty NSArray.
Here is the code:
public String getCombinedValue() throws Exception {
StringBuffer names=new StringBuffer();
NSArray
customers=(NSArray)object.storedValueForKey("suggestedCustomers");
NSLog.out.appendln("cus "+customers.componentsJoinedByString(", "));
for (int i=0; i<customers.count(); i++){
EOEnterpriseObject
suggestedCustomer=(EOEnterpriseObject)customers.objectAtIndex(i);
NSLog.out.appendln("cus"+i+" "+suggestedCustomer);
String lastName=(String)suggestedCustomer.valueForKey("lastName");
names.append(" ");
names.append(lastName);
}
return names.toString();
}
The array shows up fine, but it always has a size of zero, despite
there being two values in the tables that qualify.
FWIW, printing out object shows, among other things, suggestedCustomers
= "<com.webobjects.eocontrol._EOCheapCopyMutableArray 35cf9c
(<EOAccessArrayFaultHandler suggestedCustomers
_EOIntegralKeyGlobalID[Listing (java.lang.Integer)1]>)>".
Scott
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.