On 04/05/2010, at 11:18 AM, Chuck Hill wrote:

> On May 3, 2010, at 5:38 PM, Baiss Eric Magnusson wrote:
> 
>> I have an Owner, the Owner has many Transactions.
>> 
>> <...>
>> In the pages Constructor I used:
>> ...
>>      public ERXBatchingDisplayGroup<Transaction> curTrans;
>> ...
>>      curTrans.queryBindings().setObjectForKey( … );
>>      try  {                  
>>              curTrans.setObjectArray( theOwner.transactions() );
>>              curTrans.qualifyDataSource();
> 
> That looks... odd.  Especially this part: curTrans.setObjectArray( 
> theOwner.transactions() )  I'd expect to set ERXBatchingDisplayGroup up for 
> Transaction and use a qualifier like "owner = $owner and date >= $startMonth 
> and date < $endMonth"  Passing in theOwner.transactions() is likely to remove 
> a lot of the benefit.
> 
> 
> I don't use model (or wherever you are getting this from) display groups, so 
> I don't know what do tell you.  In code it would look something like this:
> 
> 
>            dataSource = new EODatabaseDataSource(editingContext(), 
> entityName());
> 
>            
> dataSource.fetchSpecification().setPrefetchingRelationshipKeyPaths(prefetchingRelationshipKeyPaths());
>            dataSource.fetchSpecification().setRefreshesRefetchedObjects( 
> refreshesRefetchedObjects() );
>            dataSource.fetchSpecification().setIsDeep( true );
>            dataSource().fetchSpecification().setQualifier(qualifier());
>           displayGroup.setDataSource(dataSource);
> <...>
>> What do I need to do to set the data source, I thought that <setObjectArray> 
>> was the way to do it, but no, it always crashes?
> 
> I've sketched out what I do, but I lifted that from other pieces of code, so 
> it is only a rough sketch.

Below is a another/similar sketch of usage of ERXBatchingDisplayGroup that I'm 
using. I've had to adjust a little from what I do as I'm subclassing all of 
ERXBatchingDisplayGroup, EOArrayDataSource, ERXDatabaseDataSource.

with regards,
--

Lachlan Deck


public ERXBatchingDisplayGroup getDisplayGroup()
{
        if ( this.displayGroup == null )
        {
                this.displayGroup = new ERXBatchingDisplayGroup();
                getDisplayGroup().setDelegate( new 
MyDefaultDisplayGroupDelegate() );
                
                EODataSource dataSource = null;
                if ( hasObjects() )
                {
                        EOArrayDataSource arrayDataSource = new 
EOArrayDataSource(...);
                        arrayDataSource.setArray( getObjects() );
                        dataSource = arrayDataSource;
                }
                else
                {
                        EOFetchSpecification spec = new EOFetchSpecification( 
getEntityName(), getQualifier(), getSortOrderings() );
                        spec.setUsesDistinct( true );
                        spec.setRefreshesRefetchedObjects( false );
                        
                        ERXDatabaseDataSource dbDataSource = new 
ERXDatabaseDataSource(...);
                        dbDataSource.setFetchSpecification( spec );
                        dbDataSource.setRefreshesRefetchedObjects( false );
                        
                        dataSource = dbDataSource;
                }
                getDisplayGroup().setDataSource( dataSource );
                if ( getObjectsPerBatch().intValue() > 0 )
                {
                        getDisplayGroup().setNumberOfObjectsPerBatch( 
getNumberOfObjectsPerBatch() );
                }
                
                getDisplayGroup().fetch();
                if ( getBatchIndex() != null ) // e.g., from query param
                {
                        getDisplayGroup().setCurrentBatchIndex( getBatchIndex() 
);
                        getDisplayGroup().fetch();
                }
        }
        return this.displayGroup;
} _______________________________________________
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