Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue #883
  • Loading branch information
rsoika committed Nov 8, 2024
1 parent caf8b56 commit a28de3a
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.exceptions.QueryException;

import jakarta.annotation.PostConstruct;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.util.logging.Level;
import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.exceptions.QueryException;

/**
* The ViewController can be used in JSF Applications to manage lists of
Expand Down Expand Up @@ -70,6 +72,7 @@ public class ViewController implements Serializable {
private int pageIndex = 0;
private boolean endOfList = false;
private boolean loadStubs = true;
private long totalCount = 0;

private static final Logger logger = Logger.getLogger(ViewController.class.getName());

Expand Down Expand Up @@ -181,6 +184,13 @@ public void setEndOfList(boolean endOfList) {
this.endOfList = endOfList;
}

/**
* Returns the total count of entries for the current search query.
*/
public long getTotalCount() {
return totalCount;
}

/**
* Returns the current view result. The returned result set is defined by the
* current query definition.
Expand All @@ -201,7 +211,7 @@ public List<ItemCollection> loadData() throws QueryException {
}

// load data
logger.log(Level.FINEST, "...... load data - query={0} pageIndex={1}", new Object[]{_query, getPageIndex()});
logger.log(Level.FINEST, "...... load data - query={0} pageIndex={1}", new Object[] { _query, getPageIndex() });

List<ItemCollection> result = null;
if (this.isLoadStubs()) {
Expand All @@ -214,12 +224,13 @@ public List<ItemCollection> loadData() throws QueryException {

// The end of a list is reached when the size is below or equal the
// pageSize. See issue #287
totalCount = documentService.count(_query);
if (result.size() < getPageSize()) {
setEndOfList(true);
} else {
// look ahead if we have more entries...
int iAhead = (getPageSize() * (getPageIndex() + 1)) + 1;
if (documentService.count(_query, iAhead) < iAhead) {
if (totalCount < iAhead) {
// there is no more data
setEndOfList(true);
} else {
Expand Down

0 comments on commit a28de3a

Please sign in to comment.