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);
}
entityVO = contactFacade.getEntity(Integer.parseInt(viewEntityId));
DynaActionForm entityForm = (DynaActionForm)form;
entityVO.populateFormBean(entityForm);
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("Entity", entityVO.getContactID());
Collection customFieldValues = customFieldMap.values();
int arraySize = customFieldValues.size() > 4 ? 4 : customFieldValues.size();
CustomFieldVO[] fieldArray = new CustomFieldVO[arraySize];
Iterator i = customFieldValues.iterator();
int count = 0;
while (i.hasNext() && count < 4) {
fieldArray[count++] = (CustomFieldVO)i.next();
}
entityForm.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", "Entity");
request.setAttribute("recordName", entityVO.getName());
request.setAttribute("recordId", viewEntityId);
request.setAttribute("dynamicTitle", entityVO.getName());
request.setAttribute("parentId", new Integer(entityVO.getList()));
request.setAttribute("parentName", "");
request.setAttribute("marketingList", new Integer(entityVO.getList()));
// 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");
}
// Right Nav stuff
entityForm.set("mocTypeList", Globals.MOC_TYPE);
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.ENTITY_LIST_TYPE, rpp, current);
String filter = "SELECT entity.entityId FROM entity WHERE entityId IN (" + selectedIds + ")";
listParameters.setFilter(filter);
ArrayList columns = new ArrayList();
FieldDescriptor nameField = (FieldDescriptor)ValueListConstants.entityViewMap.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);