UserObject userObject = (UserObject)session.getAttribute("userobject");
int individualId = userObject.getIndividualID();
ListPreference listPreference = userObject.getListPreference("Individual");
ListView view = listPreference.getListView(String.valueOf(listPreference.getDefaultView()));
ValueListParameters listParameters = null;
ValueListParameters requestListParameters = (ValueListParameters)request
.getAttribute("listParameters");
if (requestListParameters == null) // build up new Parameters
{
listParameters = new ValueListParameters(ValueListConstants.INDIVIDUAL_LIST_TYPE,
listPreference.getRecordsPerPage(), 1);
} else { // paging or sorting or something, use the parameters from the
// request.
listParameters = requestListParameters;
}
if (listParameters.getSortColumn() == 0) {
FieldDescriptor sortField = (FieldDescriptor)ValueListConstants.individualViewMap
.get(listPreference.getSortElement());
listParameters.setSortColumn(sortField.getQueryIndex());
if (listPreference.getsortOrder()) {
listParameters.setSortDirection("ASC");
} else {
listParameters.setSortDirection("DESC");
}
}
// Search handling
String filter = null;
String filterParameter = request.getParameter("filter");
if (filterParameter != null) {
filter = (String)session.getAttribute("listFilter");
if (filter == null) {
filter = "SELECT individual.individualId FROM individual WHERE 1=1 ";
}
// We don't want to add filter on the List in following condition
// 1) if the Action Type is for Employee Lookup
// 2) if user is seleting the All List will be identified by -1
// then we shouldn't apply the filter on list.
if ((actionType == null || (actionType != null && !actionType.equals("lookupEmployee")))
&& (marketingListId != null && !marketingListId.equals("-1"))) {
filter = filter + " AND list = " + marketingListId;
}
request.setAttribute("appliedSearch", filterParameter);
} else {
// Filter by the marketing List.
filter = "SELECT individual.individualId FROM individual WHERE 1=1 ";
// We don't want to add filter on the List in following condition
// 1) if the Action Type is for Employee Lookup
// 2) if user is seleting the All List will be identified by -1
// then we shouldn't apply the filter on list.
if ((actionType == null || (actionType != null && !actionType.equals("lookupEmployee")))
&& (marketingListId != null && !marketingListId.equals("-1"))) {
filter += " AND list = " + marketingListId;
}
session.removeAttribute("listFilter");
}
Vector viewColumns = view.getColumns();
ArrayList columns = new ArrayList();
if (actionType != null && actionType.startsWith("lookup")) {
// start hack for search in lookups
if (filter == null || filter.equals("")) {