Package com.centraview.contact.entity

Examples of com.centraview.contact.entity.EntityVOX


    int individualId = userobject.getIndividualID();

    ActionMessages allErrors = new ActionMessages();

    DynaActionForm entityForm = (DynaActionForm)form;
    EntityVO entityVO = new EntityVOX(form, request, dataSource);

    String entityName = entityVO.getName();
    if (entityName == null || entityName.length() <= 0) {
      allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField",
          "Entity Name"));
    }

    entityVO.setModifiedBy(individualId);

    ContactFacade contactFacade = null;
    try {
      contactFacade = (ContactFacade)CVUtility.setupEJB("ContactFacade",
          "com.centraview.contact.contactfacade.ContactFacadeHome", dataSource);
    } catch (Exception e) {
      throw new ServletException(e);
    }

    ActionForward forward = null;
    StringBuffer path = new StringBuffer();
    // Decide if we are updating an existing or creating a new
    if (entityVO.getContactID() < 1) {
      // set the creator
      entityVO.setCreatedBy(individualId);
      // if necessary the account manager
      if (entityVO.getAccManager() < 1) {
        entityVO.setAccManager(individualId);
      }
      String marketingListSession = (String)session.getAttribute("dbid");
      int marketingList = 1;
      try {
        marketingList = Integer.valueOf(marketingListSession).intValue();
      } catch (NumberFormatException nfe) {}

      entityVO.setList(marketingList);

      if (!allErrors.isEmpty()) {
        // if there were any validation errors, show the
        // new entity form again, with error messages...
        this.saveErrors(request, allErrors);
        return mapping.findForward(".view.contact.new_entity");
      }

      int newEntityId = contactFacade.createEntity(entityVO, individualId);

      if (request.getParameter("new") != null) {
        path.append(mapping.findForward("newEntity").getPath());
        path.append(entityVO.getList());
        forward = new ActionForward(path.toString(), true);
      } else {
        path.append(mapping.findForward("viewEntity").getPath());
        path.append(newEntityId);
        path.append("&closeWindow=false");
        forward = new ActionForward(path.toString(), true);
      }
    } else {
      try {
        contactFacade.updateEntity(entityVO, individualId);
      } catch (Exception e) {
        logger.error("[execute] Exception thrown.", e);
        throw new ServletException(e);
      }
      path.append(mapping.findForward("viewEntity").getPath());
      path.append(entityVO.getContactID());
      path.append("&closeWindow=");
      path.append(entityForm.get("closeWindow"));
      forward = new ActionForward(path.toString(), true);
    }
    return forward;
View Full Code Here

TOP

Related Classes of com.centraview.contact.entity.EntityVOX

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.