Package org.apache.struts.action

Examples of org.apache.struts.action.ActionErrors


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

    int individualID = userObject.getIndividualID();    // logged in user
   
    ActionErrors allErrors = new ActionErrors();
    String forward = ".view.email.newfolder";
    String errorForward = "errorOccurred";
   
    // "newMailFolderForm", defined in struts-config-email.xml
    DynaActionForm emailForm = (DynaActionForm)form;
View Full Code Here


      // After performing the logic in the DeleteHanlder, we are generat a new request for the list
      // 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");
      }//end of if (session.getAttribute("listErrorMessage") != null)
     
      DisplayList displaylist = ( DisplayList )request.getAttribute( "displaylist") ;
View Full Code Here

      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 = ".view.common.folderlookup";

    // "folderLookupForm", defined in struts config
    DynaActionForm emailForm = (DynaActionForm)form;

    try {
      // get the folder ID from the form bean
      Integer folderID = (Integer)emailForm.get("folderID");

      // get the actionType from the form bean
      String actionType = (String)emailForm.get("actionType");
      emailForm.set("actionType", actionType);

      // now, check the folder ID on the form...
      if (folderID == null || folderID.intValue() <= 0) {
        // if folder ID is not set on the form, then there is
        // no point in continuing forward. Show user the door. :-)
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
            "error.general.requiredField", "Parent Folder ID"));
        return (mapping.findForward(forward));
      }

      String tableName = "cvfolder";
View Full Code Here

    HttpSession session = request.getSession(true);
    UserObject userObject = (UserObject)session.getAttribute("userobject");
    int individualId = userObject.getIndividualID();
   
    //  Check the session for an existing error message (possibly from the delete handler)
    ActionErrors allErrors = (ActionErrors)session.getAttribute("listErrorMessage");
    if (allErrors != null) {
      saveErrors(request, allErrors);
      session.removeAttribute("listErrorMessage");
    }
   
View Full Code Here

  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    // initialize new actionerror object
    ActionErrors errors = new ActionErrors();
    // cache the form data
    convertItemLines();

    try {
      // initialize validation
      Validation validation = new Validation();

      validation.checkForRequired("label.hrs.hr.ReportingTo", reportto,
          "error.application.required", errors);

      validation.checkForRequired("label.hrs.hr.Employee", getEmployee(),
          "error.application.required", errors);

      validation.checkForRequired("label.hrs.hr.From", getFromday(), "error.application.required",
          errors);
      validation.checkForRequired("label.hrs.hr.To", getToday(), "error.application.required",
          errors);

      if ((getFromday() != null && getFromday().length() != 0)
          || (getFromyear() != null && (getFromyear()).length() != 0)
          || (getFrommonth() != null && (getFrommonth()).length() != 0)) {
        validation.checkForDate("label.hrs.hr.From", getFromyear(), getFrommonth(), getFromday(),
            "error.application.date", errors);
      }
      if ((getToday() != null && getToday().length() != 0)
          || (getToyear() != null && getToyear().length() != 0)
          || (getTomonth() != null && getTomonth().length() != 0)) {
        validation.checkForDate("label.hrs.hr.To", getToyear(), getTomonth(), getToday(),
            "error.application.date", errors);
      }

      if ((getFromday()) != null
          && (getFromday().length() != 0 && (getToday()) != null && (getToday()).length() != 0))
        validation.checkForDateComparison("label.hrs.hr.From", (getFromyear()), (getFrommonth()),
            (getFromday()), "label.hrs.hr.To", (getToyear()), (getTomonth()), (getToday()),
            "error.application.datecomparison", errors);
      boolean itemPresent = false;
      int counter = 0;

      if (this.itemid != null) {

        for (int i = 0; i < this.linestatus.length; i++) {
          if (this.linestatus[i] != null && this.linestatus[i].equalsIgnoreCase("Deleted")) {
            counter++;
          }
        }

        if (this.itemid.length > 0 && this.linestatus.length != counter) {
          itemPresent = true;
        }
      }

      if (itemPresent == false) {
        ActionMessage error = new ActionMessage("error.application.required", messages
            .getMessage("error.account.expense.itemsrequired"));
        errors.add("error.application.required", error);
      }

      HttpSession session = request.getSession(true);

      if (errors != 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();

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

    try
    {
      // get the file ID from the form bean
      Integer formFileID = (Integer)fileForm.get("fileID");
      // create an int to hold the file ID value
      int fileID = 0;

      // now, check the file ID on the form...
      if (formFileID == null)
      {
        // if file 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 file ID is set on the form properly, then set
        // the int representation for use in the code below
        fileID = formFileID.intValue();
View Full Code Here

    }

    HttpSession session = request.getSession(true);
    // Check the session for an existing error message (possibly from the delete
    // handler)
    ActionErrors allErrors = (ActionErrors)session.getAttribute("listErrorMessage");
    if (allErrors != null) {
      saveErrors(request, allErrors);
      session.removeAttribute("listErrorMessage");
    }
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 = "closeWindow";
    String errorForward = "errorOccurred";

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

    // Populate the Attachments In-Case. If we face any problem while sending email.
    // Populating the ArrayList with the DDNameValue.
    ArrayList attachments = new ArrayList();
    ArrayList attachmentFileIDs = new ArrayList();
    String[] tempAttachmentMap = (String[])emailForm.get("attachments");
    if (tempAttachmentMap != null && tempAttachmentMap.length > 0) {
      for (int i=0; i<tempAttachmentMap.length; i++) {
        String fileKeyName = tempAttachmentMap[i];
        if (fileKeyName != null) {
          int indexOfHash = fileKeyName.indexOf("#");
          if (indexOfHash != -1) {
            int lenString = fileKeyName.length();
            String fileID = fileKeyName.substring(0,indexOfHash);
            String fileName = fileKeyName.substring(indexOfHash+1,lenString);
            attachments.add(new DDNameValue(fileID+"#"+fileName,fileName));
            attachmentFileIDs.add(new Integer(fileID));
          }
        }
      }
    }

    //Setting the Attachments to form.
    emailForm.set("attachmentList", attachments);

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

      // get the form input and validate

      // create a MailMessageVO
      MailMessageVO messageVO = new MailMessageVO();

      Integer accountID = (Integer)emailForm.get("accountID");
      if (accountID == null || accountID.intValue() <= 0) {
        accountID = new Integer(remote.getDefaultAccountID(individualID));
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.pleaseSelect", "From: (email account)"));
      }
      messageVO.setEmailAccountID(accountID.intValue());

      MailAccountVO accountVO = remote.getMailAccountVO(accountID.intValue());
      if (accountVO == null) {
        accountVO = new MailAccountVO();
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Could not retreive account information. Please select an account."));
      }

      MailUtils mailUtils = new MailUtils();

      InternetAddress fromAddress = new InternetAddress(accountVO.getEmailAddress(), mailUtils.stripInvalidCharsFromName(accountVO.getIndividualName()));
      messageVO.setFromAddress(fromAddress.toString());

      messageVO.setReplyTo(accountVO.getReplyToAddress());


      String subject = (String)emailForm.get("subject");
      if (subject == null || subject.equals("")) {
        messageVO.setSubject("[No Subject] ");
      }else{
        messageVO.setSubject(subject);
      }

      String body = (String)emailForm.get("body");
      if (body == null) {
        body = "";
      }
      messageVO.setBody(body);

      Boolean composeInHTML = (Boolean)emailForm.get("composeInHTML");
      if (composeInHTML.booleanValue()) {
        messageVO.setContentType(MailMessageVO.HTML_TEXT_TYPE);
      }else{
        messageVO.setContentType(MailMessageVO.PLAIN_TEXT_TYPE);
      }

      ArrayList toList = this.parseAddresses((String)emailForm.get("to"));
      if (toList.size() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "To:"));
      }else{
        messageVO.setToList(toList);
      }

      ArrayList ccList = this.parseAddresses((String)emailForm.get("cc"));
      messageVO.setCcList(ccList);

      ArrayList bccList = this.parseAddresses((String)emailForm.get("bcc"));
      messageVO.setBccList(bccList);

      // TODO: figure out what headers to set when sending mail
      messageVO.setHeaders("");

      messageVO.setReceivedDate(new java.util.Date());

      // Handle attachments - the attachment handler puts a ArrayList
      // This ArrayList contains the list of attached fileIDs.
      // So we'll get that ArrayList, iterate through it, creating a
      // CvFileVO object for each attachment, then add that file VO
      // to the messageVO object which will take care of the rest in
      // the EJB layer. Note that in the future, we'll want to make
      // this better by not saving the attachment list on the session.
      // So if you intend to modify this code, please consult the rest
      // of the team to see if it makes sense to make that change now.
      // Also, if you make a change here, you must make sure the
      // attachment handling code in ForwardHandler reflects your changes.
      if (attachmentFileIDs != null && attachmentFileIDs.size() > 0) {
        CvFileFacade fileRemote  = new CvFileFacade();
       
        for (int i = 0; i < attachmentFileIDs.size(); i++) {
          int fileID = ((Integer) attachmentFileIDs.get(i)).intValue();
          // get the CvFileVO from the EJB layer
          CvFileVO fileVO = fileRemote.getFile(individualID, fileID, dataSource);
          if (fileVO != null) {
            // add this attachment to the messageVO
            messageVO.addAttachedFiles(fileVO);
          }
        }   // end while (attachIter.hasNext())
      }   // end if (attachmentMap != null && attachmentMap.size() > 0)


      if (! allErrors.isEmpty()) {
        // we encountered error above and built a list of messages,
        // so save the errors to be shown to the users, and quit
        saveErrors(request, allErrors);
        return(mapping.findForward(errorForward));
      }

      try {
        // send the message
        boolean messageSent = remote.sendMessage(accountVO, messageVO);

        if (messageSent) {
          // check to see if we just successfully delivered a saved draft
          // message. If so, then we need to delete the saved draft from
          // the database.
          Integer savedDraftID = (Integer)emailForm.get("savedDraftID");
          if (savedDraftID.intValue() > 0) {
            remote.deleteMessage(savedDraftID.intValue(), individualID);
          }
        }
      }catch(SendFailedException sfe){
        String errorMessage = sfe.getMessage();
        int startOfError = errorMessage.indexOf("<error>");
        int endOfError = errorMessage.indexOf("</error>");
        if (startOfError >= 0 && endOfError >= 0){
          // For any specific error catch and tagged inside the <error> </error>. we will parse and Display to the user.
          String finalParsedMessage = errorMessage.substring((startOfError+7),endOfError);
          allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Error while sending mail. "+finalParsedMessage));
        } else{
          allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Error while sending mail. Please check the recipients for invalid addresses."));
        }
        saveErrors(request, allErrors);
        return(mapping.findForward(errorForward));
      }
    }catch(Exception e){
      System.out.println("[Exception][SendHandler] Exception thrown in execute(): " + e.toString());
      e.printStackTrace();
      allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.unknownError", "error.unknownError"));
      saveErrors(request, allErrors);
      return(mapping.findForward(errorForward));
    }
    return(mapping.findForward(forward));
  }
View Full Code Here

        // After performing the logic in the DeleteHanlder, we are generat a new request for the list
        // 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");
        }//end of if (session.getAttribute("listErrorMessage") != null)
       
        if (strInvoiceID != null)
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.