saveErrors(request, allErrors);
session.removeAttribute("listErrorMessage");
}
ListPreference listPreference = userObject.getListPreference("Opportunity");
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.OPPORTUNITY_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.opportunityViewMap.get(listPreference.getSortElement());
listParameters.setSortColumn(sortField.getQueryIndex());
if (listPreference.getsortOrder()) {
listParameters.setSortDirection("ASC");
} else {
listParameters.setSortDirection("DESC");
}
}
//Columns and lookups
String actionType = (String)request.getParameter("actionType");
//TODO Consolodate listScope and superScope.
// my pending or all
String listScope = request.getParameter("listScope");
if (listScope != null && listScope.equals("all")) {
finalForward = ".view.sales.opportunity.list.all";
listScope = "all";
} else {
finalForward = ".view.sales.opportunity.list.my";
listScope = "my";
}
//If we are working on the lookup then we can't filter on my opportunity
//We have to do it with the help of all opportunity
// Search handling
String filter = null;
if (actionType != null && actionType.equals("lookup")) {
listScope = "all";
filter = " SELECT OpportunityID FROM opportunity ";
}
String filterParameter = request.getParameter("filter");
if (filterParameter != null) {
filter = (String)session.getAttribute("listFilter");
if (listScope.equals("my")) {
filter += " AND Status = '1' AND AccountManager = '" + individualId + "'";
session.setAttribute("listFilter", filter);
}
request.setAttribute("appliedSearch", filterParameter);
} else {
if (listScope.equals("my")) // 1 is pending
{
filter = "SELECT OpportunityID FROM opportunity WHERE Status = '1' AND AccountManager = '" + individualId + "'";
}
session.removeAttribute("listFilter");
}
int entityId = 0;
if (((request.getParameter("entityId")) != null) && (!((request.getParameter("entityId")).equals("")))) {
entityId = Integer.parseInt(request.getParameter("entityId"));
}
Vector viewColumns = view.getColumns();
ArrayList columns = new ArrayList();
if (actionType != null && actionType.startsWith("lookup")) {
Vector lookupViewColumns = new Vector();
lookupViewColumns.add("Title");
lookupViewColumns.add("Entity");