I have made acouple of modifications:
-
made the code independend from extLib
-
added categoryTotals
-
added sorting ( ascending/ descending )
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import javax.faces.context.FacesContext;
import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.Session;
import lotus.domino.View;
import lotus.domino.ViewEntry;
import lotus.domino.ViewNavigator;
public class CategoryBean {
private String viewName;
private String server;
private String databasePathAndName;
private int categoryColumn;
private boolean isInitialized;
private List entries;
private List categoryValues;
private TreeMap categoryTotals;
private FacesContext fc = FacesContext.getCurrentInstance();
private Session session = (Session) fc.getApplication()
.getVariableResolver().resolveVariable(fc, "session");
public int getCategoryColumn() {
return categoryColumn;
}
public void setCategoryColumn(int categoryColumn) {
this.categoryColumn = categoryColumn;
}
public String getViewName() {
return viewName;
}
public void setViewName(String viewName) {
this.viewName = viewName;
}
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getDatabasePathAndName() {
return databasePathAndName;
}
public void setDatabasePathAndName(String databasePathAndName) {
this.databasePathAndName = databasePathAndName;
}
public CategoryBean() {
}
public List getAllEntries() {
if (!isInitialized)
init();
return entries;
}
@SuppressWarnings("unchecked")
public List getEntries(String categoryValue) {
if (!isInitialized)
init();
ArrayList entriesOfCategory = new ArrayList();
if (entries != null) {
Iterator it = entries.iterator();
for (; it.hasNext();) {
Entry e = (Entry) it.next();
List