public ActionForward editPartyContact(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws FenixServiceException {
   if (getRenderedObject("edit-contact") instanceof PartyContactBean) {
     PartyContactBean contact = getRenderedObject("edit-contact");
     Boolean wasValidated = false;
     try {
       if (contact.hasPartyContact()) {
         addActionMessage(
             "contacts", request, "label.contact.validate.already", contact.getValue());
         return backToShowInformation(mapping, actionForm, request, response);
       }
       wasValidated = editContact(contact);
     } catch (DomainException e) {
       addActionMessage("contacts", request, e.getMessage(), e.getArgs());
     }
     if (wasValidated) {
       addWarningMessage(request, contact);
       return forwardToInputValidationCode(
           mapping, actionForm, request, response, contact.getContact());
     }
     return backToShowInformation(mapping, actionForm, request, response);
   }
   return null;
 }
 public ActionForward createPartyContact(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws FenixServiceException {
   if (getRenderedObject("edit-contact") instanceof PartyContactBean) {
     PartyContactBean contact = getRenderedObject("edit-contact");
     PartyContact newPartyContact = null;
     try {
       newPartyContact = createContact(contact);
       if (newPartyContact == null) {
         addActionMessage(
             "contacts", request, "label.contact.validate.already", contact.getValue());
         return backToShowInformation(mapping, actionForm, request, response);
       } else {
         addWarningMessage(request, contact);
       }
     } catch (DomainException e) {
       addActionMessage("contacts", request, e.getMessage(), e.getArgs());
     }
     return forwardToInputValidationCode(mapping, actionForm, request, response, newPartyContact);
   }
   return null;
 }
 public ActionForward prepareEditPartyContact(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response) {
   PartyContact contact = getPartyContact(request);
   PartyContactBean contactBean = PartyContactBean.createFromDomain(contact);
   request.setAttribute("partyContact", contactBean);
   request.setAttribute("partyContactClass", contactBean.getContactName());
   return mapping.findForward("editPartyContact");
 }
 public ActionForward invalid(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response) {
   Object rendered = getRenderedObject("edit-contact");
   if (rendered instanceof PartyContactBean) {
     PartyContactBean contact = (PartyContactBean) rendered;
     contact.setVisibleToManagement(Boolean.TRUE);
     request.setAttribute("partyContact", contact);
     request.setAttribute("partyContactClass", contact.getContactName());
   } else if (rendered instanceof PhysicalAddress) {
     PhysicalAddress contact = (PhysicalAddress) rendered;
     request.setAttribute("partyContact", contact);
     request.setAttribute("partyContactClass", contact.getClass().getSimpleName());
   }
   return backToEditOrCreate(mapping, actionForm, request, response);
 }
 private ActionForward prepareCreatePartyContact(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response,
     PartyContactBean bean) {
   request.setAttribute("person", getParty(request));
   request.setAttribute("partyContactClass", bean.getContactName());
   return mapping.findForward("createPartyContact");
 }
 public ActionForward prepareValidate(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response) {
   final String partyContactExtId = request.getParameter("partyContact");
   PartyContact partyContact = FenixFramework.getDomainObject(partyContactExtId);
   partyContact.triggerValidationProcessIfNeeded();
   PartyContactBean contactBean = PartyContactBean.createFromDomain(partyContact);
   addWarningMessage(request, contactBean);
   return forwardToInputValidationCode(mapping, actionForm, request, response, partyContact);
 }
 public ActionForward postbackSetElements(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response) {
   PartyContactBean contact = getRenderedObject("edit-contact");
   RenderUtils.invalidateViewState();
   if (contact.getVisibleToPublic().booleanValue()) {
     contact.setVisibleToPublic(
         new Boolean(
             contact.getVisibleToStudents().booleanValue()
                 && contact.getVisibleToStaff().booleanValue()));
   }
   contact.setVisibleToManagement(Boolean.TRUE);
   request.setAttribute("partyContact", contact);
   request.setAttribute("partyContactClass", contact.getContactName());
   return backToEditOrCreate(mapping, actionForm, request, response);
 }
 public ActionForward forwardToInputValidationCode(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response,
     PartyContact partyContact) {
   if (partyContact == null || !isToBeValidated(partyContact)) {
     return backToShowInformation(mapping, actionForm, request, response);
   }
   final PartyContactValidation partyContactValidation = partyContact.getPartyContactValidation();
   request.setAttribute("partyContactValidation", partyContactValidation.getExternalId());
   request.setAttribute("valid", partyContactValidation.isValid());
   request.setAttribute("tries", partyContactValidation.getAvailableTries());
   if (partyContact instanceof PhysicalAddress) {
     request.setAttribute("isPhysicalAddress", true);
     request.setAttribute(
         "physicalAddressBean", new PhysicalAddressBean((PhysicalAddress) partyContact));
   }
   request.setAttribute("partyContact", PartyContactBean.createFromDomain(partyContact));
   request.setAttribute(
       "canValidateRequests", ((Person) partyContact.getParty()).getCanValidateContacts());
   return mapping.findForward("inputValidationCode");
 }
 protected void addWarningMessage(HttpServletRequest request, PartyContactBean contactBean) {
   addActionMessage(
       "contacts", request, contactBean.getValidationMessageKey(), contactBean.getValue());
 }
 protected void addWarningMessage(HttpServletRequest request, PartyContact partyContact) {
   PartyContactBean contactBean = PartyContactBean.createFromDomain(partyContact);
   addActionMessage(
       "contacts", request, contactBean.getValidationMessageKey(), contactBean.getValue());
 }