Package org.apache.struts.action

Examples of org.apache.struts.action.ActionMessage


      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


          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);
View Full Code Here

      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

      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

      ActionMessages allErrors = new ActionMessages();

      // now, check the account ID on the form...
      if (invenForm.getItemName() == null || invenForm.getItemName().length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
            "error.general.requiredField", "Item"));
      }

      // now, check the account ID on the form...
      if (invenForm.getLocationName() == null || invenForm.getLocationName().length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
            "error.general.requiredField", "Location"));
      }
      int invID = 0;

      if (invenForm != null)
View Full Code Here

      remote.setDataSource(dataSource);

      Integer ruleID = (Integer)ruleForm.get("ruleID");
      if (ruleID == null || ruleID.intValue() <= 0)
      {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Rule ID"));
      }



      RuleVO oldRuleVO = remote.getRule(ruleID.intValue());
      RuleVO newRuleVO = new RuleVO();

      newRuleVO.setRuleID(ruleID.intValue());
      newRuleVO.setAccountID(accountID.intValue());

      // 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{
        newRuleVO.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{
        newRuleVO.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{
        newRuleVO.setEnabled(enabled.booleanValue());
      }

      // moveMessage - if true, then folderID is required. Default to false.
      // HACK!!!! Because we're using checkboxes on a DynaActionForm that we
      // are sticking onto the session, we needed to do the following hack:
      // I created a hidden HTML input field on the JSP. It is initially set
      // to the value of "moveMessage" from the database. When the user checks
      // or unchecks the checkbox, then the hidden field is either set to true
      // or false (respectively). Therefore, in this handler we only care about
      // the value of the HIDDEN field, and don't even bother to check the value
      // of the "moveMessage" property of the form bean. This same hack is
      // also used for "markMessageRead and" "deleteMessage"
      String moveMessageParam = (String)request.getParameter("moveMessageHidden");
      boolean moveMessage = false;
      if (moveMessageParam != null && moveMessageParam.equals("true"))
      {
        newRuleVO.setMoveMessage(true);
        moveMessage = true;
      }else{
        newRuleVO.setMoveMessage(false);
      }

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

      // markMessageRead - Default to false. NOTE THE HACK (explained above)!!!
      String markMessageReadParam = (String)request.getParameter("markMessageReadHidden");
      boolean markMessageRead = false;
      if (markMessageReadParam != null && markMessageReadParam.equals("true"))
      {
        newRuleVO.setMarkMessageRead(true);
        markMessageRead = true;
      }else{
        newRuleVO.setMarkMessageRead(false);
      }

      // deleteMessage - Default to false. NOTE THE HACK (explained above)!!!
      String deleteMessageParam = (String)request.getParameter("deleteMessageHidden");
      boolean deleteMessage = false;
      if (deleteMessageParam != null && deleteMessageParam.equals("true"))
      {
        newRuleVO.setDeleteMessage(true);
        deleteMessage = true;
      }else{
        newRuleVO.setDeleteMessage(false);
      }

      // At least one of moveMessage OR deleteMessage OR markMessageRead MUST be selected
      if (deleteMessage == false && moveMessage == false && markMessageRead == 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.setRuleID(ruleID.intValue());
            ruleCriteriaVO.setOrderID(count);
            ruleCriteriaVO.setExpressionType(criteria.getExpressionType());
View Full Code Here

      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);
    }
    ActionForward forward = new ActionForward(request.getParameter("currentPage"), true);
    return forward;
  }
View Full Code Here

      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);
    }
    String returnPath = request.getParameter("currentPage");
    if(returnPath == null){
      returnPath = mapping.findForward(".view.accounting.inventorylist").getPath();
View Full Code Here

      Validation validation = new Validation();

      this.convertPaymentLines();

      if (this.getEntityId() == null || this.getEntityId().trim().length() <= 0) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Entity"));
      }

      if (errors != null)
      {
        request.setAttribute("body", "ADD");
View Full Code Here

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

      // subject
      if (this.getSubject() == null || this.getSubject().trim().length() <= 0) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Subject"));
      }

      // status
      if (this.getStatus() == null || this.getStatus().trim().length() <= 0) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Status"));
      }

      //priority
      if (this.getPriority() == null || this.getPriority().trim().length() <= 0) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Priority"));
      }

      if (errors != null) {
        request.setAttribute("ticketform", this);
      }
View Full Code Here

TOP

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

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.