Re: ERXBatchingDisplayGroup and insertObjectAtIndex
Re: ERXBatchingDisplayGroup and insertObjectAtIndex
- Subject: Re: ERXBatchingDisplayGroup and insertObjectAtIndex
- From: David Avendasora <email@hidden>
- Date: Sun, 27 Feb 2011 17:18:53 -0500
On Feb 27, 2011, at 11:59 AM, Anjo Krank wrote:
> The batching DG has very different semantics than the non-batching one. Basically, all of the EC changing stuff won't work as planned. You can safely only use it for querying large data sets.
>
> You should only add a ticket if you also provide a fix,
Which is why I said "a ticket to patch", as I would be providing a patch, and I showed the code I would be submitting.
> which I estimate is very hard to do correctly. (EG, you need to insert the items in the correct sort order, so that re-loading the page will put them where they belong, filter out deleted objects etc.)
What we have been doing is inserting objects at index 0, then manually calling setSortOrderings and updateDisplayedObjects, and I don't see how actually updating the rowCount and batchCount would break anything worse than it already is broken. Currently, if you insert an object at an index that is in the middle of a batch, it _will_ show up, but the last object in the last batch will now drop off instead of creating a new batch and showing up there.
I'm not sure how it can be considered to be working now, and I don't believe what I'm proposing will change the behavior of either of the things you mention.
Dave
>
> Cheers, Anjo
>
>
>
> Am 27.02.2011 um 14:59 schrieb David Avendasora:
>
>> Hi All,
>>
>> Is there a reason why the ERXBatchingDisplayGroup wouldn't increment the _rowCount variable when you call insertObjectAtIndex?
>>
>> If you have a BDG that has a rowCount() that is an exact multiple (including 0) of the numberOfObjectsPerBatch() and you insert a new object, the rowCount() doesn't change and therefore neither will the batchCount(). Since the batchCount() didn't increase, any objects that would have been displayed in the last (new) batch are not displayed, and won't be until you refetch, even if you sort.
>>
>> Overriding insertObjectAtIndex in ERXBatchingDisplayGroup like this:
>>
>> @Override
>> public void insertObjectAtIndex(Object createObject, int newIndex) {
>> super.insertObjectAtIndex(createObject,
>> newIndex);
>> setRowCount(_rowCount + 1);
>> }
>>
>> and then modifying setRowCount to also call updateBatchCount()
>>
>> public void setRowCount(int rowCount) {
>> _rowCount = rowCount;
>> updateBatchCount();
>> }
>>
>> will fix the problem I'm having, but I don't know if I'm missing some other problem that this will cause.
>>
>> If this is the correct change to make, then we should also override deleteObjectAtIndex as that will change the rowCount as well.
>>
>> @Override
>> public boolean deleteObjectAtIndex(int anIndex) {
>> boolean objectDeleted = super.deleteObjectAtIndex(anIndex);
>> if (objectDeleted) {
>> setRowCount(_rowCount - 1);
>> }
>> return objectDeleted;
>> }
>>
>> Does anyone have any input?
>>
>> If not, I'm going to create a Jira ticket to patch ERXBatchingDisplayGroup.
>>
>> Dave
>> _______________________________________________
>> 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
>
>
_______________________________________________
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