Examples of ActionErrors


Examples of org.apache.struts.action.ActionErrors

  private static final long serialVersionUID = 1L;

  @Override
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    ActionErrors errors = new ActionErrors();
    errors.add("projectName", new ActionMessage("another.error"));
    return errors;
  }
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

    HttpServletRequest request = createStrictMock(HttpServletRequest.class);
    NavigableFormRenderBean actionBean = createStrictMock(NavigableFormRenderBean.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    ActionErrors errors = new ActionErrors();
    errors.add("prop", new ActionMessage("key"));
    expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(errors);
    actionBean.setInputError(true);
    actionBean.execute();
    expect(form.getBindOutwards()).andReturn(false);
    expect(actionBean.getSuccessResult()).andReturn("success");
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

    HttpServletRequest request = createStrictMock(HttpServletRequest.class);
    BasicFormAction actionBean = createStrictMock(BasicFormAction.class);
    ActionMapping mapping = createStrictMock(ActionMapping.class);
    DelegatingForm form = createStrictMock(DelegatingForm.class);

    ActionErrors errors = new ActionErrors();
    errors.add("prop", new ActionMessage("key"));
    expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(errors);
    actionBean.setInputError(true);
    expect(actionBean.execute()).andReturn("success");
    expect(form.getBindOutwards()).andReturn(false);
    expect(mapping.findForward("success")).andReturn(actionForward);
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  {

    HttpServletRequest request = createStrictMock(HttpServletRequest.class);
    HttpSession session = createStrictMock(HttpSession.class);

    final ActionErrors actionErrors = new ActionErrors();
    EasyMock.expect(request.getAttribute(Globals.ERROR_KEY)).andReturn(actionErrors);
    EasyMock.expect(request.getSession()).andReturn(session);
    session.setAttribute(Globals.ERROR_KEY, actionErrors);
   
    replay(request);
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  }

  @Test
  public void testNullIntegerValidation()
  {
    ActionErrors errors = delegator.validate(null, null);
    ActionMessage element = (ActionMessage) errors.get("requiredInteger").next();
    assert element != null;
  }
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {

    ActionErrors errors = new ActionErrors();

    boolean hasError = false;

    if (title == null)
    {
      ActionMessage error = new ActionMessage("Title cannot be null", false);
      errors.add("title", error);
      hasError = true;
    }

    if (days == null)
    {
      ActionMessage error = new ActionMessage("Days cannot be null", false);
      errors.add("days", error);
      hasError = true;
    }
    else
    {
      if (!GenericValidator.isInt(days))
      {
        ActionMessage error = new ActionMessage("Days must be number", false);
        errors.add("days", error);
        hasError = true;
      }
    }

    if (startDate == null)
    {
      ActionMessage error = new ActionMessage("Start date cannot be null", false);
      errors.add("startDate", error);
      hasError = true;
    }
    else
    {

      if (!GenericValidator.isDate(startDate, "yyyy-MM-dd", false))
      {
        ActionMessage error = new ActionMessage("Start date must be a date in yyyy-MM-dd", false);
        errors.add("startDate", error);
        hasError = true;
      }
    }

    if (!hasError)
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

      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

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 = ".forward.preference.mail.account_list";
    String errorForward = ".view.preference.mail.new_account";

    // "mailAccountForm" defined in struts-config-preference.xml
    DynaActionForm accountForm = (DynaActionForm)form;

    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");

    try {
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      // build a MailAccountVO
      MailAccountVO accountVO = new MailAccountVO();

      // the owner is always the logged in user
      accountVO.setOwnerID(individualID);

      // account name - required
      String accountName = (String)accountForm.get("accountName");
      if (accountName == null || accountName.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Account Name"));
      }
      accountVO.setAccountName(accountName);

      // server type - "pop3" by default
      String accountType = MailAccountVO.POP3_TYPE;
      if ((String)accountForm.get("serverType") != null) {
        if (((String)accountForm.get("serverType")).equals("imap")) {
          accountType = MailAccountVO.IMAP_TYPE;
        }
      }
      accountVO.setAccountType(accountType);

      // default account - if user has no other accounts,
      // then make this one the default, else not default
      boolean defaultAccount = false;
      int defaultAccountID = remote.getDefaultAccountID(individualID);

      if (defaultAccountID == 0) {
        defaultAccount = true;
      }
      accountVO.setDefaultAccount(defaultAccount);

      // email address - must be a valid InternetAddress
      String emailAddress = (String)accountForm.get("emailAddress");
      if (emailAddress == null) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Email Address"));
      } else if (! CVUtility.isEmailAddressValid(emailAddress)) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.email.invalidAddress", emailAddress));
      }
      accountVO.setEmailAddress(emailAddress);

      // leave on server - false by default
      Boolean leaveOnServerForm = (Boolean)accountForm.get("leaveOnServer");
      boolean leaveOnServer = false;
      if (leaveOnServerForm != null && leaveOnServerForm.booleanValue() == true) {
        leaveOnServer = true;
      }
      accountVO.setLeaveMessagesOnServer(leaveOnServer);

      // user name - required
      String username = (String)accountForm.get("username");
      if (username == null || username.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "User Name (login)"));
      }
      accountVO.setLogin(username);

      // password - required
      String password = (String)accountForm.get("password");
      if (password == null || password.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Password"));
      }
      accountVO.setPassword(password);

      // mail server (POP3 or IMAP) - required
      String mailServer = (String)accountForm.get("mailServer");
      if (mailServer == null || mailServer.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Mail Server Address"));
      }
      accountVO.setMailServer(mailServer);
     
      // reply to - optional
      String replyTo = (String)accountForm.get("replyTo");
      accountVO.setReplyToAddress(replyTo);

      // signature - optional
      String signature = (String)accountForm.get("signature");
      accountVO.setSignature(signature);

      // port - required, must be valid Integer
      Integer smtpPort = (Integer)accountForm.get("port");
      if (smtpPort == null || smtpPort.intValue() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "SMTP Port"));
      }
      accountVO.setSmtpPort(smtpPort.intValue());

      // smtp server - required
      String smtpServer = (String)accountForm.get("smtpServer");
      if (smtpServer == null || smtpServer.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "SMTP Server"));
      }
      accountVO.setSmtpServer(smtpServer);

      Boolean authenticationRequiredForSMTP = (Boolean)accountForm.get("authenticationRequiredForSMTP");
      if (authenticationRequiredForSMTP != null) {
        if (authenticationRequiredForSMTP.booleanValue()) {
          accountVO.setAuthenticationRequiredForSMTP(true);
        } else {
          accountVO.setAuthenticationRequiredForSMTP(false);
        }
      }


      // These are all the default settings for an account. They should not change
      accountVO.setLastFetchedCount(0);
      accountVO.setLastFetchedDate(new java.util.Date());
      accountVO.setLastUID("");
      accountVO.setSupportAccount(false);

      // TODO: implement setForceSecureConnection in the future
      accountVO.setForceSecureConnection(false);

      // TODO: implement setPopRequiredBeforeSMTP in the future
      accountVO.setPopRequiredBeforeSMTP(false);

      // TODO: implement setPopRequiredBeforeSMTP in the future
      accountVO.setPopRequiredBeforeSMTP(false);


      if (! allErrors.isEmpty()) {
        saveErrors(request, allErrors);
        return(mapping.findForward(errorForward));
      }
     
      int newAccountID = 0;
      try {
        newAccountID = remote.addEmailAccount(accountVO);
      } catch (MessagingException me) {
        String errorMessage = me.getMessage();
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Error while creating email account, "+errorMessage));
        saveErrors(request, allErrors);
        return mapping.findForward(errorForward);
      }

      if (newAccountID <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Could not add email account. Please check the values you entered, and try again."));
        saveErrors(request, allErrors);
        return(mapping.findForward(errorForward));
      }
    } catch (Exception e) {
      logger.error("[Exception] SaveNewAccountHandler.Execute Handler ", e);
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

  public ActionErrors validate (ActionMapping mapping, HttpServletRequest request)
  {
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();

    // initialize new actionerror object
    ActionErrors errors = new ActionErrors();

    try
    {
      Validation validation = new Validation();

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

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

      // Literature
      String ids = this.getLiteratureid();

      // check if user have entered any data
      if ( (this.getDuebyyear() != null && this.getDuebyyear().length() != 0) ||
           (this.getDuebymonth() != null && this.getDuebymonth().length() != 0) ||
           (this.getDuebyday() != null && this.getDuebyday().length() != 0) ||
           (this.getDuebytime() != null && this.getDuebytime().length() != 0)) {

        // validation.checkForDate("error.literature.duedate", this.getDuebyyear(), this.getDuebymonth(), this.getDuebyday(), "error.application.date", "", errors);
        // validation.checkForDateComparison("error.literature.currentdate", this.getCurrentyear(), this.getCurrentmonth(), this.getCurrentday(), "00:00 AM", "error.literature.duedate", this.getDuebyyear(), this.getDuebymonth(), this.getDuebyday(), "00:00 AM", "error.application.datecomparison", "", errors, "error.literature.currentdate", "error.literature.duedate");
      }


      if ((ids == null) || (ids.equals(""))) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Literature"));
      }

      // redirect to jsp if errors present
      if (errors != null)
      {
View Full Code Here

Examples of org.apache.struts.action.ActionErrors

   */
  public ActionErrors validate (ActionMapping mapping, HttpServletRequest request)
  {
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
    // initialize new actionerror object
    ActionErrors errors = new ActionErrors();
    convertItemLines();

    //Incase if the Form is having some error then we must have to carry the jurisdiction Vec
    try{
      AccountHelperHome accountHelperHome = (AccountHelperHome)CVUtility.getHomeObject("com.centraview.account.helper.AccountHelperHome","AccountHelper");
      AccountHelper accHelper =(AccountHelper)accountHelperHome.create();
      accHelper.setDataSource(dataSource);
      this.jurisdictionVec = accHelper.getTaxJurisdiction();
    }catch(Exception e){
      this.jurisdictionVec = new Vector();
    }

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

      // invoice
      if (this.getOrderid() == null || this.getOrderid().trim().length() <= 0) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Order"));
      }
     
      if (this.getDate() == null || this.getDate().trim().length() <= 0) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Date"));
      }
     
      boolean itemPresent =false;
      int counter = 0;

      if (this.itemid != null)
      {
        ItemLines lines = this.getItemLines();

        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)
      {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requierdField", "Items"));
      }



      if (errors != null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.