ValueList valueList = null;
try {
valueList = valueListHome.create();
} catch (CreateException e) {
logger.error("[execute] Exception thrown.", e);
throw new ServletException(e);
}
valueList.setDataSource(dataSource);
ValueListVO listObject = valueList.getValueList(individualId, listParameters);
ArrayList buttonList = new ArrayList();
ValueListDisplay displayParameters = null;
if (actionType != null && actionType.startsWith("lookup")) {
displayParameters = new ValueListDisplay(buttonList, false, false);
if (actionType.equals("lookup_attendee")) {
if (entityId != 0) {
StringBuffer parameterValues = new StringBuffer();
parameterValues.append(ValueListConstants.AMP);
parameterValues.append("entityId=" + entityId);
listObject.setCurrentPageParameters(parameterValues.toString());
request.setAttribute("hideMarketingList", new Boolean(true));
}
// When we select the lookup then we should add the Select button to the
// valueList
buttonList.add(new Button("Select", "select", "lu_selectList('lookup_attendee');", false));
buttonList.add(new Button("New Individual", "new", "c_newButton('Individual', 15)", false));
request.setAttribute("dynamicTitle", "Individual Members");
request.setAttribute("lookupType", "Individual Members");
displayParameters.setRadioToCheckBox(true);
}
if (actionType.equals("lookup")) {
if (entityId != 0) {
StringBuffer parameterValues = new StringBuffer();
parameterValues.append(ValueListConstants.AMP);
parameterValues.append("entityId=" + entityId);
listObject.setCurrentPageParameters(parameterValues.toString());
request.setAttribute("hideMarketingList", new Boolean(true));
}
// When we select the lookup then we should add the Select button to the
// valueList
buttonList.add(new Button("Select", "select", "lu_selectList('Individual');", false));
buttonList.add(new Button("New Individual", "new", "c_newButton('Individual', 15)", false));
request.setAttribute("dynamicTitle", "Individual");
request.setAttribute("lookupType", "Individual");
}
if (actionType.equals("lookupEmployee")) {
request.setAttribute("hideMarketingList", new Boolean(true));
// When we select the lookup then we should add the Select button to the
// valueList
if (request.getParameter("lookupFlag") != null) {
buttonList.add(new Button("Select", "select", "lu_selectList('Employee', '"
+ request.getParameter("lookupFlag") + "');", false));
} else {
buttonList.add(new Button("Select", "select", "lu_selectList('Employee');", false));
}
// buttonList.add(new Button("New Individual", "new",
// "c_newButton('Individual', 15)", false));
String defaultEntityName = java.net.URLEncoder.encode(userObject.getEntityName(),
"ISO-8859-1");
buttonList.add(new Button("New Individual", "new",
"c_openWindow('/contacts/new_individual.do?entityNo=1&entityName=" + defaultEntityName
+ "')", false));
request.setAttribute("dynamicTitle", "Employee");
request.setAttribute("lookupType", "Employee");
}
displayParameters.setRadio(true);
listObject.setLookup(true);
listObject.setLookupType(actionType);
} else {
buttonList.add(new Button("View", "view", "vl_viewList();", false));
buttonList.add(new Button("Delete", "delete", "vl_deleteList();", false));
displayParameters = new ValueListDisplay(buttonList, true, true);
}
displayParameters.setSortable(true);
displayParameters.setPagingBar(true);
displayParameters.setLink(true);
listObject.setDisplay(displayParameters);
request.setAttribute("valueList", listObject);
// Handle non-deleted users
ArrayList userList = new ArrayList();
ArrayList ar = (ArrayList)session.getAttribute("usersNotDeleted");
session.removeAttribute("usersNotDeleted");
if (ar != null && !ar.isEmpty()) {
Iterator it = ar.iterator();
while (it.hasNext()) {
String rowId = (String)it.next();
ArrayList rows = (ArrayList)listObject.getList();
Iterator iter = rows.iterator();
while (iter.hasNext()) {
ValueListRow vlr = (ValueListRow)iter.next();
if (vlr.getRowId() == Integer.parseInt(rowId)) {
userList.add(vlr.getRowData().get(2));
}
}
if (userList != null && !userList.isEmpty()) {
request.setAttribute("usersNotDeleted", userList);
}
}
}
// Put the MarketingList names on the request so the dropdown on the left
// can be rendered
ContactFacadeHome cfh = (ContactFacadeHome)CVUtility.getHomeObject(
"com.centraview.contact.contactfacade.ContactFacadeHome", "ContactFacade");
ContactFacade remote = null;
try {
remote = cfh.create();
} catch (CreateException e) {
logger.error("[execute] Exception thrown.", e);
throw new ServletException(e);
}
remote.setDataSource(dataSource);
Vector allDBList = remote.getDBList(individualId);
request.setAttribute("AllDBList", allDBList);
// For the searchBar