ContactFacadeHome aa = (ContactFacadeHome)CVUtility.getHomeObject(
"com.centraview.contact.contactfacade.ContactFacadeHome", "ContactFacade");
ContactFacade remote = aa.create();
remote.setDataSource(dataSource);
DynaActionForm dynaForm = (DynaActionForm)form;
String recordType = "";
if (isEntity) {
recordType = "Entity";
EntityVO entityVO = remote.getEntity(Integer.parseInt(rowID));
contactObject = entityVO;
dynaForm.set("name", entityVO.getName());
request.setAttribute("name", entityVO.getName());
} else {
recordType = "Individual";
IndividualVO individualVO = remote.getIndividual(Integer.parseInt(rowID));
contactObject = individualVO;
dynaForm.set("name", individualVO.getFirstName() + " " + individualVO.getLastName());
request
.setAttribute("name", individualVO.getFirstName() + " " + individualVO.getLastName());
}
dynaForm.set("ContactID", Integer.toString(contactObject.getContactID()));
dynaForm.set("EntityType", Boolean.toString(isEntity));
request.setAttribute("EntityType", Boolean.toString(isEntity));
request.setAttribute("closeWindow", request.getAttribute("closeWindow"));
request.setAttribute("refreshWindow", request.getAttribute("refreshWindow"));
Iterator mocIterator = contactObject.getMOC().iterator();
ArrayList phoneNumbers = new ArrayList();
ArrayList emailAddresses = new ArrayList();
String primaryEmailAddress = new String();
while (mocIterator.hasNext()) {
MethodOfContactVO methodOfContact = (MethodOfContactVO)mocIterator.next();
if (methodOfContact.getMocType() == 1) // this is for email
{
// If the email address is a default email address,
// add it at the begining of the list.
if ((methodOfContact.getIsPrimary()).equalsIgnoreCase("YES")) {
emailAddresses.add(0, methodOfContact);
primaryEmailAddress = methodOfContact.getContent();
} else {
emailAddresses.add(methodOfContact);
}
} else {// phone number
if (methodOfContact.getMocOrder() != null
&& phoneNumbers.size() >= Integer.parseInt(methodOfContact.getMocOrder())) {
phoneNumbers.add(Integer.parseInt(methodOfContact.getMocOrder()), methodOfContact);
} else {
phoneNumbers.add(methodOfContact);
}
}
}
dynaForm.set("phoneMOCOrder", phoneNumbers);
dynaForm.set("emailMOCOrder", emailAddresses);
dynaForm.set("primaryEmailAddress", new String[] { primaryEmailAddress });
returnStatus = ".view.contact.change_moc";
request.setAttribute("recordType", recordType);
request.setAttribute("recordName", request.getParameter("recordName"));
request.setAttribute("recordId", rowID);
request.setAttribute("dynamicTitle", request.getParameter("recordName"));