Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in ERXBatchingDisplayGroup.rowCount when used with objectArray #332

Closed
NochEinKamel opened this issue Nov 26, 2012 · 1 comment

Comments

@NochEinKamel
Copy link
Contributor

I'm using an ERXFlickrBatchNavigation to display an ERXBatchingDisplayGroup to display an manually filtered objectArray.

_acls = new ERXBatchingDisplayGroup<CRACL>();
_acls.setObjectArray(someArray);    
_acls.setNumberOfObjectsPerBatch(30);

In ERXBatchingDisplayGroup the method displayNameCount calls rowCount() in case the displayGroup is an ERXBatchingDisplayGroup

public Integer displayNameCount(){
...
        if (displayGroup() instanceof ERXBatchingDisplayGroup) {
            displayNameCount = Integer.valueOf(((ERXBatchingDisplayGroup)displayGroup()).rowCount());
...     
    return displayNameCount;
}

In ERXBatchingDisplayGroup a null-check is missing:

...
else {
    rowCount = dataSource().fetchObjects().count();
}
...

Possible fix:

if (dataSource() != null) {
    rowCount = dataSource().fetchObjects().count();
}
else if (allObjects() != null) {
    rowCount = allObjects().count();
}
@darkv
Copy link
Member

darkv commented Nov 27, 2012

If you need a display group for a simple object array you probably should use ERXDisplayGroup instead as ERXBatchingDisplayGroup is primarily to avoid fetching too many objects from database. Though ERXBatchingDisplayGroup should be fixed.

Fixed in integration 1e318ba

@darkv darkv closed this as completed Nov 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants