Package org.apache.struts.action

Examples of org.apache.struts.action.ActionErrors


      {
        try{
          remote.updateKB(individualID, knowledgeVO);
        }
        catch(KBException e){
          ActionErrors allErrors = new ActionErrors();
          String errorMessage = e.getExceptionDescription();
          if (errorMessage != null && !errorMessage.equals("")){
            allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", errorMessage));
            saveErrors(request, allErrors);
            FORWARD_final = "newkb";
            return (mapping.findForward(FORWARD_final));
          }// end of if (startOfError >= 0 && endOfError >= 0)
View Full Code Here


    HttpSession session = request.getSession();
    UserObject userObject = (UserObject)session.getAttribute("userobject");

    int individualID = userObject.getIndividualID();    // logged in user

    ActionErrors allErrors = new ActionErrors();
    String forward = "mailList";
    String errorForward = "errorOccurred";

    // "markReadForm", defined in struts-config-email.xml
    DynaActionForm emailForm = (DynaActionForm)form;
View Full Code Here

    // So we will not be carrying the old error. So that we will try to collect
    // the error from the Session variable
    // Then destory it after getting the Session value
    if (session.getAttribute("listErrorMessage") != null)
    {
      ActionErrors allErrors = (ActionErrors)session.getAttribute("listErrorMessage");
      saveErrors(request, allErrors);
      session.removeAttribute("listErrorMessage");
    }

    KnowledgebaseList displaylist = null;
View Full Code Here

    UserObject userObject = (UserObject)session.getAttribute("userobject");

    int individualID = userObject.getIndividualID();    // logged in user
    int entityID = userObject.getEntityId();    // entityID of the logged-in user's entity
   
    ActionErrors allErrors = new ActionErrors();

    // "customerKbForm", defined in cv-struts-config.xml
    DynaActionForm kbForm = (DynaActionForm)form;

    try
    {
      // get the kb ID from the form bean
      Integer formKbID = (Integer)kbForm.get("kbID");
      // create an int to hold the kb ID value
      int kbID = 0;

      // now, check the kb ID on the form...
      if (formKbID == null)
      {
        // if kb ID is not set on the form, then there is
        // no point in continuing forward. Show the user an
        // error and quit.
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Knowledgebase ID"));
        return(mapping.findForward(forward));
      }else{
        // if kb ID is set on the form properly, then set
        // the int representation for use in the code below
        kbID = formKbID.intValue();
View Full Code Here

    } catch(Exception e) {
      logger.error("[execute] Exception thrown.", e);
      throw new CommunicationException(e.getMessage());
    }
    if (!deleteLog.isEmpty()) {
      ActionErrors allErrors = new ActionErrors();
      allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You do not have permission to delete one or more of the records you selected."));
      session.setAttribute("listErrorMessage", allErrors);
    }
    return new ActionForward(request.getParameter("currentPage"), true);
  }
View Full Code Here

    HttpSession session = request.getSession();
    UserObject userObject = (UserObject)session.getAttribute("userobject");

    int individualID = userObject.getIndividualID();    // logged in user

    ActionErrors allErrors = new ActionErrors();
    String forward = "showRulesList";
    String errorForward = "errorOccurred";

    // "ruleForm", defined in struts-config-email.xml
    DynaActionForm ruleForm = (DynaActionForm)form;

    Integer accountID = new Integer(0);

    try {
      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      RuleVO ruleVO = new RuleVO();

      // name - required field
      String ruleName = (String)ruleForm.get("name");
      if (ruleName == null || ruleName.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Name"));
      }else{
        ruleVO.setRuleName(ruleName);
      }

      // description - required field
      String description = (String)ruleForm.get("description");
      if (description == null || description.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Description"));
      }else{
        ruleVO.setDescription(description);
      }

      // enabled - required field, but default to true if it's not given (shouldn't ever happen)
      Boolean enabled = (Boolean)ruleForm.get("enabled");
      if (enabled == null) {
        enabled = new Boolean(true);
      }else{
        ruleVO.setEnabled(enabled.booleanValue());
      }

      // accountID - required field. But user can't fix the error if it's not supplied :-(
      accountID = (Integer)ruleForm.get("accountID");
      if (accountID == null || accountID.intValue() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Account ID"));
      }else{
        ruleVO.setAccountID(accountID.intValue());
      }

      // moveMessage - if true, then folderID is required. Default to false.
      Boolean moveMessage = (Boolean)ruleForm.get("moveMessage");
      if (moveMessage == null) {
        moveMessage = new Boolean(false);
      }else{
        ruleVO.setMoveMessage(moveMessage.booleanValue());
      }

      // folderID = required only if moveMessage == true
      Integer folderID = (Integer)ruleForm.get("folderID");
      if (moveMessage.booleanValue() == true) {
        if (folderID == null || folderID.intValue() <= 0) {
          allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You must choose a destination when moving a message."));
        }else{
          ruleVO.setFolderID(folderID.intValue());
        }
      }

      // markMessageRead - Default to false.
      Boolean markMessageRead = (Boolean)ruleForm.get("markMessageRead");
      if (markMessageRead == null) {
        markMessageRead = new Boolean(false);
      }else{
        ruleVO.setMarkMessageRead(markMessageRead.booleanValue());
      }

      // deleteMessage - Default to false.
      Boolean deleteMessage = (Boolean)ruleForm.get("deleteMessage");
      if (deleteMessage == null) {
        deleteMessage = new Boolean(false);
      }else{
        ruleVO.setDeleteMessage(deleteMessage.booleanValue());
      }

      // At least one of moveMessage OR deleteMessage OR markMessageRead MUST be selected
      if (deleteMessage.booleanValue() == false && moveMessage.booleanValue() == false && markMessageRead.booleanValue() == false) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You must select at least one Action."));
      }

      // search criteria - get the List of SearchCriteriaVO's from the form
      // and check to see if there is at least ONE valid criteria. If not,
      // throw an error.
      List searchCriteria = Arrays.asList((SearchCriteriaVO[])ruleForm.get("searchCriteria"));
      if (searchCriteria == null || searchCriteria.isEmpty()) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You must supply at least one Criteria,"));
      }else{
        Iterator iter = searchCriteria.iterator();
        int count = 1;
        while (iter.hasNext()) {
          SearchCriteriaVO criteria = (SearchCriteriaVO)iter.next();
          if (criteria == null || criteria.getValue() == null || (criteria.getValue()).length() <= 0) {
            allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "The Criteria field cannot be blank. (line " + count + ")"));
          }else{
            RuleCriteriaVO ruleCriteriaVO = new RuleCriteriaVO();
            ruleCriteriaVO.setOrderID(count);
            ruleCriteriaVO.setExpressionType(criteria.getExpressionType());

            try{
              ruleCriteriaVO.setFieldID(Integer.parseInt(criteria.getFieldID()));
            }catch(NumberFormatException nfe){
              ruleCriteriaVO.setFieldID(-1);
            }

            try{
              ruleCriteriaVO.setConditionID(Integer.parseInt(criteria.getConditionID()));
            }catch(NumberFormatException nfe){
              ruleCriteriaVO.setConditionID(4);
            }

            ruleCriteriaVO.setValue(criteria.getValue());
            ruleVO.addRuleCriteria(ruleCriteriaVO);
          }
          count++;
        }
      }

      // if there are any errors at this point, then don't attempt to add the
      // rule to the database, just give the user the errors
      if (! allErrors.isEmpty()) {
        this.saveErrors(request, allErrors);
        return(mapping.findForward(errorForward));
      }

      // if everything's cool, then add the rule to the database...
View Full Code Here

    String forward = ".view.customer.file_list";
    HttpSession session = request.getSession();
    UserObject userObject = (UserObject)session.getAttribute("userobject");
    int individualID = userObject.getIndividualID(); // logged in user
    int entityID = userObject.getEntityId(); // logged in user's entityID
    ActionErrors allErrors = new ActionErrors();
    try {
      ListPreference listPrefs = userObject.getListPreference("File");
      String filter = "SELECT FileID FROM cvfile WHERE CustomerView='YES' AND (relateEntity = " + entityID + " OR relateIndividual = " + individualID + ")";
      ValueListParameters listParameters = ActionUtil.valueListParametersSetUp(listPrefs, request, ValueListConstants.CUSTOMER_FILE_LIST_TYPE, ValueListConstants.customerFileViewMap, false);
      listParameters.setFilter(filter);
      ValueList valueList = (ValueList)CVUtility.setupEJB("ValueList", "com.centraview.valuelist.ValueListHome", dataSource);
      ValueListVO listObject = valueList.getValueList(individualID, listParameters);
      ValueListDisplay displayParameters = new ValueListDisplay(new ArrayList(), false, false, true, true, true, true);
      listObject.setDisplay(displayParameters);
      request.setAttribute("valueList", listObject);
    } catch (Exception e) {
      logger.error("[execute] Exception thrown.", e);
      allErrors.add("error.unknownError", new ActionMessage("error.unknownError"));
    }
    if (!allErrors.isEmpty()) {
      saveErrors(request, allErrors);
    }
    return (mapping.findForward(forward));
  } // end execute() method
View Full Code Here

    request.setAttribute("showTicketSearch", new String("true"));
    HttpSession session = request.getSession();
    UserObject userObject = (UserObject)session.getAttribute("userobject");
    int individualID = userObject.getIndividualID(); // logged in user
    int entityID = userObject.getEntityId(); // logged in user's entityID
    ActionErrors allErrors = new ActionErrors();
    try {
      ListPreference listPrefs = userObject.getListPreference("Ticket");
      String filter = "SELECT t.ticketid FROM ticket t LEFT JOIN entity e ON (t.entityid=e.entityid) LEFT JOIN individual i ON (e.entityid=i.entity) WHERE i.individualid=" + individualID;
      ValueListParameters listParameters = ActionUtil.valueListParametersSetUp(listPrefs, request, ValueListConstants.CUSTOMER_TICKET_LIST_TYPE, ValueListConstants.customerTicketViewMap, false);
      listParameters.setFilter(filter);
      ValueList valueList = (ValueList)CVUtility.setupEJB("ValueList", "com.centraview.valuelist.ValueListHome", dataSource);
      ValueListVO listObject = valueList.getValueList(individualID, listParameters);

      ArrayList buttonList = new ArrayList();
      buttonList.add(new Button("New Ticket", "new", "c_goTo('/customer/new_ticket.do');", false));

      ValueListDisplay displayParameters = new ValueListDisplay(buttonList, false, false, true, true, true, true);
      listObject.setDisplay(displayParameters);
      request.setAttribute("valueList", listObject);
    } catch (Exception e) {
      logger.error("[execute] Exception thrown.", e);
      allErrors.add("error.unknownError", new ActionMessage("error.unknownError"));
    }
    if (!allErrors.isEmpty()) {
      saveErrors(request, allErrors);
    }
    return (mapping.findForward(forward));
  } // end execute() method
View Full Code Here

    HttpSession session = request.getSession();
    UserObject userObject = (UserObject)session.getAttribute("userobject");
   
    int individualID = userObject.getIndividualID();
   
    ActionErrors allErrors = new ActionErrors();
    String forward = "mailList";
    String errorForward = "errorOccurred";
   
    DynaActionForm emailForm = (DynaActionForm)form;
    Integer folderID = (Integer)emailForm.get("folderID");
View Full Code Here

    UserObject userObject = (UserObject)session.getAttribute("userobject");

    int individualID = userObject.getIndividualID();    // logged in user
    int entityID = userObject.getEntityId();    // logged in user

    ActionErrors allErrors = new ActionErrors();

    // "customerProfileForm", defined in cv-struts-config.xml
    DynaActionForm profileForm = (DynaActionForm)form;

    // get the customer profile from the database
    ContactFacadeHome cfh = (ContactFacadeHome)CVUtility.getHomeObject("com.centraview.contact.contactfacade.ContactFacadeHome","ContactFacade");
   
    try {
      ContactFacade remote = (ContactFacade)cfh.create();
      remote.setDataSource(dataSource);
     
      // get the Entity record of the logged-in user's Entity
      EntityVO entityVO = (EntityVO)remote.getEntity(entityID);
     
      if (entityVO == null) {
        // let the user know something bad happened
        allErrors.add("error.general.databaseError", new ActionMessage("error.general.databaseError"));
        entityVO = new EntityVO();
      }
     
      IndividualVO primaryContactVO = entityVO.getIndividualVO();
      if (primaryContactVO == null) {
        // avoid null pointers
        primaryContactVO = new IndividualVO();
      }
     
      AddressVO primaryAddress = entityVO.getPrimaryAddress();
      if (primaryAddress == null) {
        // avoid null pointers
        primaryAddress = new AddressVO();
      }
     
      // now, populate the form bean with the data
      profileForm.set("entityName", entityVO.getName());
      profileForm.set("firstName", primaryContactVO.getFirstName());
      profileForm.set("middleName", primaryContactVO.getMiddleName());
      profileForm.set("lastName", primaryContactVO.getLastName());
      profileForm.set("title", primaryContactVO.getTitle());
      profileForm.set("street1", primaryAddress.getStreet1());
      profileForm.set("street2", primaryAddress.getStreet2());
      profileForm.set("city", primaryAddress.getCity());
      profileForm.set("zipCode", primaryAddress.getZip());
      profileForm.set("website", primaryAddress.getWebsite());
     
      GlobalMasterLists gml = GlobalMasterLists.getGlobalMasterLists(dataSource);
      Vector stateList = (Vector)gml.get("States");
      profileForm.set("state", primaryAddress.getStateName());
      Vector countryList = (Vector)gml.get("Country");
      profileForm.set("country", primaryAddress.getCountryName());
     
      Collection mocList = entityVO.getMOC();
      Iterator iterator = mocList.iterator();
      int count = 1;
      while (iterator.hasNext()) {
        MethodOfContactVO moc = (MethodOfContactVO)iterator.next();
        if (moc.getMocType() == 1 && moc.getIsPrimary().equalsIgnoreCase("YES")) {
          // this is for email
          profileForm.set("email", moc.getContent());
        } else if (count < 4 && moc.getMocType() != 1) {
          profileForm.set("mocType" + count, new Integer(moc.getMocType()).toString());
          String mocContent = moc.getContent();
          String mocContentValue = "";
          String mocContentExt = "";
          if (mocContent.indexOf("EXT") != -1) {
            String tempContent = mocContent;
            mocContentValue = tempContent.substring(0,tempContent.indexOf("EXT"));
            mocContentExt = tempContent.substring(tempContent.indexOf("EXT")+3,tempContent.length())  ;
          }else{
            mocContentValue = mocContent;
          }
          profileForm.set("mocContent" + count, mocContentValue );
          profileForm.set("mocExt" + count, mocContentExt );
          count++;
        }
      }
     
      if (! allErrors.isEmpty()) {
        saveErrors(request, allErrors);
      }
    }catch(Exception e){
      logger.error("[Exception] CustomerProfileHandler.Execute Handler ", e);
    }
View Full Code Here

TOP

Related Classes of org.apache.struts.action.ActionErrors

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.