Hmm.. what you said gave me the hint to the problem! The code was just to iterate over an array using an iterator:

for (Iterator iterator = events().iterator(); iterator.hasNext();) { ...

Doing this the iterator is empty, because I'm guessing _EOCheapCopyMutableArray.iterator() doesn't fire the fault.

But changing the code to this works just fine:

                NSArray events = events();
                for(int i=0; i<events.count(); i++) { ...


Ok, important lesson.. stay away from iterators. Thanks for your help guys!

Jacob



On 4-Aug-07, at 8:07 PM, Ken Anderson wrote:

Jacob,

As Alexander said, it should be faulting automatically. Can you please provide the code you're using?

Basically, when you ask for the value for a key, it IS still a fault, because you haven't asked the array anything that the fault can't answer. When you do count(), it can't answer, so it fires the fault. We need to see the code you're using to compute the value you're displaying so we can see why the fault isn't firing.

Ken



On Aug 4, 2007, at 7:48 PM, Jacob Mouka wrote:

It's not the model, it's a faulting issue (it's been a while since I've worked in wo, so bare with me).

When I called the method it was still a fault (hence the _EOCheapCopyMutableArray, instead of a filled-in array). My method now looks like:

    public NSArray events() {
        NSArray events = (NSArray)storedValueForKey("events");
events.count(); //this forces EOF to read the database and create objects.
        return events;
    }

This works, but is there a "cleaner" way of doing this? Something like willRead() but equivalent for arrays? I know I could do

if(events instanceof _EOCheapCopyMutableArray) {
        ((_EOCheapCopyMutableArray)events).willRead()
}

but that's really ugly. Please enlighten :) ... what's the standard way of dealing with this?

Oh and one more thing: I was wrong about this being a displaygroup- only issue.. it comes up anytime this object is used and before it's been fetched (into the databasestore or something) the first time.

Thanks, Jacob




On 4-Aug-07, at 6:43 PM, Alexander Spohr wrote:

Jacob,

EOF _does_ fetch any relationship automatic - no matter how you access your EOs relationship.

There must be an error in your EOModel, your EOs or somewhere else.

        atze


Am 04.08.2007 um 21:38 schrieb Jacob Mouka:

Hi List... I'm wondering about EOs' relationships when they are in a displaygroup. Basically on a page the user clicks to select an EO from a displaygroup, and the selected EO iterates over a to-many relationship to summarize some data, but the problem is the array it gets from it's valueForKey method is empty (com.webobjects.eocontrol._EOCheapCopyMutableArray). I know it's a faulting issue because I can bind the relationship to a worepetition just to display it, and it shows up fine. So my question is how can I get webobjects to fetch the array on a call to valueForKey? I think the old way of doing this would be to call willRead, but that doesn't work.

Also, if the same EO is fetched using a plain old fetchspecification it's relationships are intact, so what does a displaygroup do differently?

Jacob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/atze% 40freeport.de

This email sent to [EMAIL PROTECTED]

Freeport & Soliversum
Alexander Spohr
[EMAIL PROTECTED]
www.freeport.de



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kenlists% 40anderhome.com

This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to