Check out ERXEOControlUtilities.objectCountWithQualifier. Do note, though, that you’ll be performing a count on the DB for each iteration of your repetition, so in some cases (like if you don’t have many related objects) you might be better off just performing a prefetch on the relationship.
Cheers, - hugi > On 27. feb. 2016, at 17:30, ocs.cz <[email protected]> wrote: > > Hello there, > > I've got a page which lists a number of relationships; for each of them the > user wants to see the number of objects, i.e., essentially something like > this: > > === > <wo:repeat list="..." item="$item"> > for <wo:str value="$item.title"/><br/> > - we got <wo:str value="$item.relationship1.count"/> <!-- here's the problem > --> > rel1 items <wo:hyperlink action="$showItemRel1">show</wo:hyperlink><br/> > - we got <wo:str value="$item.relationship2.count"/> <!-- ditto --> > rel2 items <wo:hyperlink action="$showItemRel2">show</wo:hyperlink><br/> > ... > </wo:repeat> > === > > The first time this page gets displayed, all the relationships are fetched of > course. That, alas, takes a small eternity, not speaking of the memory > consumption. And it is rather superfluous, for of all the relationships, only > one or two will typically be actually shown. > > Since the numbers of items are, alas, needed and cannot be simply omitted to > show them only after the user clicks showItemRelN, I would need a solution to > get a number of items in a relationship quickly without actually fetching > them. That would probably mean exploiting SQL COUNT somehow (but only if the > relationship is not fetched yet, of course; if already happens to be fetched, > simple count is self-evidently most efficient). Hopefully, SQL COUNT will be > fast enough to do each time (if not, some caching and > JS-based-lazy-count-loading etc. will be needed and hilarity will ensue, but > at the moment, I really hope SQL COUNT would suffice). > > Is there a pre-made solution for this in WOnder (or even plain WO) which I > have missed so far, or am I out to DIMyself? > > Thanks a lot, > OC > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/hugi%40karlmenn.is > > 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: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
