Package org.apache.struts.action

Examples of org.apache.struts.action.ActionErrors


    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


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

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

    ActionErrors allErrors = new ActionErrors();

    DynaActionForm profileForm = (DynaActionForm)form;

  EmailSettingsHome emailSettingsHome = (EmailSettingsHome)CVUtility.getHomeObject("com.centraview.administration.emailsettings.EmailSettingsHome","EmailSettings");
   
    try {
    EmailSettings emailSettingsRemote = (EmailSettings)emailSettingsHome.create();
    emailSettingsRemote.setDataSource(dataSource);

    // Its a predefined Template for the replying message for the Change Of user Information Information
    EmailTemplateForm userInfoTemplateForm = emailSettingsRemote.getEmailTemplate(AdministrationConstantKeys.EMAIL_TEMPLATE_USER_PROFILE);
    String toAddress = userInfoTemplateForm.getToAddress();
    String fromAddress = userInfoTemplateForm.getFromAddress();
    String replyTo = userInfoTemplateForm.getReplyTo();
    String emailSubject = userInfoTemplateForm.getSubject();
    String emailBody = userInfoTemplateForm.getBody();

    MailMessageVO mailMessage = new MailMessageVO();
    ArrayList toList = new ArrayList();
    toList.add(toAddress);
    mailMessage.setToList(toList);
    mailMessage.setHeaders("Change Of User Information");
    mailMessage.setContentType("text/plain");
    mailMessage.setFromAddress(fromAddress);
    mailMessage.setReplyTo(replyTo);
    mailMessage.setSubject(emailSubject);


    StringBuffer body = new StringBuffer("");
    body.append(emailBody);
    body.append("\n\nUser Information Change Request:\n\n");

    DynaActionForm dynaForm = (DynaActionForm)form;

    String entityName = (String)dynaForm.get("individualName");
    body.append("Individual Name: " + entityName + "\n");

    String title = (String)dynaForm.get("title");
    body.append("Title: " + title + "\n");

    String street1 = (String)dynaForm.get("street1");
    body.append("Street1: " + street1 + "\n");

    String street2 = (String)dynaForm.get("street2");
    body.append("Street2: " + street2 + "\n");

    String city = (String)dynaForm.get("city");
    body.append("City: " + city + "\n");

    String state = (String)dynaForm.get("state");
    body.append("State: " + state + "\n");

    String zipCode = (String)dynaForm.get("zipCode");
    body.append("Zip Code: " + zipCode + "\n");

    String country = (String)dynaForm.get("country");
    body.append("Country: " + country + "\n");

    String mocContent = "";
    String mocTypeName = "";
      if (dynaForm.get("email") != null) {
        mocContent = (dynaForm.get("email") == null) ? "" : (String)dynaForm.get("email");
      body.append("Email: " + mocContent + "\n");
      }

    for(int i=1 ; i<4 ; i++ ){
      mocContent = CVUtility.getMOCContent(dynaForm, i+"");
      int mocType = Integer.parseInt((String)dynaForm.get("mocType"+i));
      mocTypeName = CVUtility.getSyncAs(mocType);
      body.append(mocTypeName+": " + mocContent + "\n");
      }

    body.append("\n\n\nLogin Information Change Request:\n\n");

    Integer userID = (Integer)dynaForm.get("userID");
    body.append("UserID: " + userID.toString() +"\n");

    String username = (String)dynaForm.get("username");
    body.append("Username: " + username +"\n");

    String oldPassword = (String)dynaForm.get("oldPassword");
    body.append("Old Password: " + oldPassword + "\n");

    String newPassword = (String)dynaForm.get("newPassword");
    body.append("New Password: " + newPassword + "\n");

    String newPasswordConf = (String)dynaForm.get("newPasswordConf");
    body.append("Confirm Password: " + newPasswordConf  + "\n");

    body.append("\n\nEnd CentraView Web Request\n");

    mailMessage.setBody(body.toString());

      boolean messageSent = false;
      try {
        messageSent = emailSettingsRemote.simpleMessage(individualID,mailMessage);
      } catch(Exception e) {
        allErrors.add("error.customer.profile.emailSendFailure", new ActionMessage("error.customer.profile.emailSendFailure"));
        saveErrors(request, allErrors);
        //return(mapping.findForward(".view.customer.view_user"));
        return(mapping.findForward(".view.customer.user_change_confirm"));
      }

      if (! messageSent) {
      // if email message is not sent, let the user know we suck
      allErrors.add("error.customer.profile.emailSendFailure", new ActionMessage("error.customer.profile.emailSendFailure"));
    }
    }catch(Exception e){
      // if an exception occurs, then print a message to the log file,
      // direct the user to the Customer Profile form, and show them
      // an error.
      logger.error("[Exception] UpdateUserHandler.Execute Handler ", e);
      allErrors.add("error.unknownError", new ActionMessage("error.unknownError"));
      forward = ".view.customer.view_user";
      e.printStackTrace();
    }

    if (! allErrors.isEmpty()) {
      // no point in saving errors to the request if there aren't any
      saveErrors(request, allErrors);
    }

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

  */
  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {

    // initialize new actionerror object
    ActionErrors errors = new ActionErrors();
    HttpSession session = null;
    try
    {
      // initialize validation
      Validation validation = new Validation();

      validation.checkForRequired("label.hr.newtimesheet.reportingto", ((String)get("reportingTo")), "error.application.required", errors);
      validation.checkForRequired("label.hr.newtimesheet.employee", ((String)get("employee")), "error.application.required", errors);
      validation.checkForRequired("label.hr.newtimesheet.fromdate", ((String)get("fromday")), "error.application.required", errors);
      validation.checkForRequired("label.hr.newtimesheet.todate", ((String)get("toyear")), "error.application.required", errors);

      if (
        ((String)get("fromday") != null && ((String)get("fromday")).length() != 0) ||
         ((String)get("fromyear") != null && ((String)get("fromyear")).length() != 0) ||
         ((String)get("frommonth") != null && ((String)get("frommonth")).length() != 0)
         )
      {
        validation.checkForDate("label.hr.newtimesheet.fromdate", ((String)get("fromyear")), ((String)get("frommonth")), ((String)get("fromday")), "error.application.date", errors);
      }
      if (
         (((String)get("today")) != null && ((String)get("today")).length() !=0) ||
         (((String)get("toyear")) != null && ((String)get("toyear")).length() !=0) ||
         (((String)get("tomonth")) != null && ((String)get("tomonth")).length() !=0)
        )
        {
        validation.checkForDate("label.hr.newtimesheet.todate", ((String)get("toyear")), ((String)get("tomonth")), ((String)get("today")), "error.application.date", errors);
      }

      if(((String)get("fromday")) != null && ((String)get("fromday")).length() != 0 && ((String)get("today")) != null && ((String)get("today")).length() !=0)
        validation.checkForDateComparison ("label.hr.newtimesheet.fromdate", ((String)get("fromyear")), ((String)get("frommonth")),((String)get("fromday")), "label.hr.newtimesheet.todate", ((String)get("toyear")), ((String)get("tomonth")), ((String)get("today")), "error.application.datecomparison", errors);

      session = request.getSession(true);

    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
    finally
    {
      String sAddSlipFlag = (String)request.getAttribute("addslip");
      request.setAttribute("addslip",sAddSlipFlag);
      request.setAttribute("timesliplist",session.getAttribute("timesliplist"));
      String sAction = (String)session.getAttribute("TYPEOFOPERATION");
      if(!errors.isEmpty() && (sAction != null && sAction.equalsIgnoreCase("EDIT")))
        session.setAttribute("ERRORSPRESENT","EDIT");
    }
    return errors;
  }
View Full Code Here

    Integer accountID = (Integer)emailForm.get("accountID");
   
    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

    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
    String rowId[]=null;
    String listType=null;

    String FORWARD_NAME="";
    ActionErrors allErrors = new ActionErrors();
   
    HttpSession session = request.getSession(true);

    rowId =request.getParameterValues("rowId");//request can be to delete mutiple rows
    listType=request.getParameter("listType");//get the list type in this case it better be File
    String listId = request.getParameter("listId");//get its ID,  for some reason.

    long idd = 0;

    if(listId != null)
      idd = Long.parseLong( listId  );

    ListGenerator lg = ListGenerator.getListGenerator(dataSource);


    FileList displayList = (FileList)lg.getDisplayList(idd);//get the FileList from LG
    FileList displayListSession = ( FileList )session.getAttribute( "displaylist") ;


    if((displayListSession!=null)&&(displayListSession.getListID()==idd))
      displayListSession.setDirtyFlag(true);

    UserObject  userobjectd = (UserObject)session.getAttribute( "userobject" );
    int individualID = userobjectd.getIndividualID();//get the individualId of the user logged in
    displayList.setDataSource(dataSource);
    ArrayList deleteLog = displayList.deleteElement(individualID, rowId);//deletes the element
    displayList.setDirtyFlag(true);

    if(deleteLog != null && !deleteLog.isEmpty()){
      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);
    }

    request.setAttribute( "displaylist" , displayList);
    // If listFor is set on the request we must assume we came from the relatedInfo area
View Full Code Here

  private float fBreakMins;
  private float fBreakTime;

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    ActionErrors errors = new ActionErrors();

    try {
      if (request.getParameter("timeslip") != null) {
        if (request.getParameter("timeslip").equalsIgnoreCase("support")) {

          if ((String)get("description") == null
              || ((String)get("description")).trim().length() <= 0) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
                "error.general.requiredField", "Description"));
          }
        }
      } else {
        String project = (String)get("project");
        if (project != null && (!project.equals(""))) {

          if ((String)get("reference") == null || ((String)get("reference")).trim().length() <= 0) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
                "error.general.requiredField", "Reference"));
          }

          if ((String)get("task") == null || ((String)get("task")).trim().length() <= 0) {
            errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
                "error.general.requiredField", "Task"));
          }
        }

        if ((String)get("description") == null || ((String)get("description")).trim().length() <= 0) {
          errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
              "error.general.requiredField", "Description"));
        }
      }

      int startHrs = 0, startMins = 0, endHrs = 0, endMins = 0;

      if (((String)get("startTime")) != null && !(((String)get("startTime")).equals(""))) {
        int[] startTime = CVUtility.convertTimeTo24HrsFormat((String)get("startTime"));
        startHrs = startTime[0];
        startMins = startTime[1];
      }

      if (((String)get("endTime")) != null && !(((String)get("endTime")).equals(""))) {
        int[] endTime = CVUtility.convertTimeTo24HrsFormat((String)get("endTime"));
        endHrs = endTime[0];
        endMins = endTime[1];
      }

      if (startHrs > endHrs) {
        ActionMessage error = new ActionMessage("error.application.timecomparison", "EndTime",
            "StartTime");
        errors.add("error.application.timecomparison", error);
      } else if (startHrs == endHrs && startMins > endMins) {
        ActionMessage error = new ActionMessage("error.application.timecomparison", "EndTime",
            "StartTime");
        errors.add("error.application.timecomparison", error);
      }

      fBreakHrs = Float.parseFloat((String)get("breakHours"));
      fBreakMins = Float.parseFloat((String)get("breakMinutes"));
      fBreakTime = 0;

      if (fBreakMins != 0) {
        fBreakTime = fBreakHrs + fBreakMins / 60;
      } else {
        fBreakTime = fBreakHrs;
      }

      float remMin = 0;
      if (startMins != 0 && endMins != 0) {
        if (endMins > startMins) {
          remMin = 60 / (endMins - startMins);
        } else {
          remMin = 60 / (startMins - endMins);
        }
      }

      Float Duration = new Float((endHrs - startHrs) + remMin - fBreakTime);
      if (Duration.floatValue() <= 0.0) {
        ActionMessage error = new ActionMessage("error.projects.timeslip.totaltimediff",
            "Start and End Time difference", "BreakTime");
        errors.add("error.projects.timeslip.totaltimediff", error);
      }
    } catch (Exception e) {
      logger.error("[validate]: Exception", e);
    }
    return errors;
View Full Code Here

    String forward = ".view.customer.faq_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("FAQ");
      String filter = "SELECT faq.faqid FROM faq WHERE publishToCustomerView='YES' and status='PUBLISH'";
      ValueListParameters listParameters = ActionUtil.valueListParametersSetUp(listPrefs, request, ValueListConstants.CUSTOMER_FAQ_LIST_TYPE, ValueListConstants.customerFaqViewMap, 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

      catch(CvFileException e)
      {
        request.setAttribute("closeWindow", "false");
        saveandclose = "";
        saveandnew = null;
        ActionErrors allErrors = new ActionErrors();
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "The Folder with This Name Already Exists On this Location"));
        saveErrors(request, allErrors);
      }
     
      if (saveandnew != null) {
        folderForm.setDescription("");
View Full Code Here

        System.out.println("[Exception][SaveEditFolderHandler.execute] Exception Thrown: "+e);
        e.printStackTrace();
        request.setAttribute("closeWindow", "false");
        saveandclose = "";
        saveandnew = null;
        ActionErrors allErrors = new ActionErrors();
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "The Folder with This Name Already Exists On this Location"));
        saveErrors(request, allErrors);
        request.setAttribute("closeWindow","false");
      }

      if (saveandnew != 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.