try {
contactFacade = (ContactFacade)CVUtility.setupEJB("ContactFacade",
"com.centraview.contact.contactfacade.ContactFacadeHome", dataSource);
} catch (Exception e) {
logger.error("[execute] Exception thrown.", e);
throw new ServletException(e);
}
IndividualVO individualVO = contactFacade.getIndividual(Integer.parseInt(viewIndividualId));
individualVO.populateFormBean(individualForm);
// Now we need to get the custom field stuff because it doesn't live on the
// individualVO even though there is a nice space for it there
CustomField customField = null;
try {
customField = (CustomField)CVUtility.setupEJB("CustomField",
"com.centraview.customfield.CustomFieldHome", dataSource);
} catch (Exception e) {
logger.error("[execute] Exception thrown.", e);
throw new ServletException(e);
}
// Only 8 custom fields fit on the detail screen so we have to pull only the
// first 8 out.
TreeMap customFieldMap = customField.getCustomFieldData("Individual", individualVO
.getContactID());
Collection customFieldValues = customFieldMap.values();
int arraySize = customFieldValues.size() > 8 ? 8 : customFieldValues.size();
CustomFieldVO[] fieldArray = new CustomFieldVO[arraySize];
Iterator i = customFieldValues.iterator();
int count = 0;
while (i.hasNext() && count < 8) {
fieldArray[count++] = (CustomFieldVO)i.next();
}
individualForm.set("customFields", fieldArray);
// Useful Stuff for the request (common things for every type of screen so
// we don't have to program for each different form bean)
request.setAttribute("recordType", "Individual");
request.setAttribute("recordName", individualVO.getFullName());
request.setAttribute("recordId", viewIndividualId);
request.setAttribute("dynamicTitle", individualVO.getFullName());
request.setAttribute("parentId", new Integer(individualVO.getEntityID()));
request.setAttribute("parentName", individualVO.getEntityName());
request.setAttribute("marketingList", new Integer(individualVO.getList()));
individualForm.set("mocTypeList", Globals.MOC_TYPE);
// end getting the data together for the main window.
// if we clicked copy to, then show this data on the simple copyto jsp.
if (request.getParameter("copyTo") != null) {
return mapping.findForward(".view.contact.copyto");
}
// get the list together for the right nav
int rpp = 15;
String currentParam = request.getParameter("current");
int current = 1;
try {
current = Integer.valueOf(currentParam).intValue();
} catch (Exception e) {}
String selectedIds = request.getParameter("rowId");
ValueListParameters listParameters = new ValueListParameters(
ValueListConstants.INDIVIDUAL_LIST_TYPE, rpp, current);
String filter = "SELECT individual.individualId FROM individual WHERE individualId IN ("
+ selectedIds + ")";
listParameters.setFilter(filter);
ArrayList columns = new ArrayList();
FieldDescriptor nameField = (FieldDescriptor)ValueListConstants.individualViewMap.get("Name");
listParameters.setSortColumn(nameField.getQueryIndex());
listParameters.setSortDirection("ASC");
columns.add(nameField);
listParameters.setColumns(columns);
ValueList valueList = null;
try {
valueList = (ValueList)CVUtility.setupEJB("ValueList",
"com.centraview.valuelist.ValueListHome", dataSource);
} catch (Exception e) {
logger.error("[execute] Exception thrown.", e);
throw new ServletException(e);
}
ValueListVO listObject = valueList.getValueList(individualId, listParameters);
// Paging stuff.
int total = listObject.getParameters().getTotalRecords();
long totalPages = (long)Math.ceil((double)total / rpp);