@RequestMapping(value = "/wfstepUpdate", method = RequestMethod.POST)
  @RequestScoped
  public String updateWFStep(
      @ModelAttribute("wfstepAdd") WFStep wfstep,
      HttpServletRequest request,
      Model model,
      HttpServletResponse response) {
    response.setCharacterEncoding("UTF-8");
    Long duplicateId = 0l;
    try {
      duplicateId =
          wfstepService.updateDuplicateCheck(
              wfstep.getWfstepNameEdit(),
              wfstep.getWfstepidEdit(),
              wfstep.getWfstepStageGUIDEdit());

      if (duplicateId == 0) {
        wfstep.setWfstepid(wfstep.getWfstepidEdit());
        wfstep.setWfstepStageGUID(wfstep.getWfstepStageGUIDEdit());
        wfstep.setWfstepStatus(wfstep.getWfstepStatusEdit());
        wfstep.setWfstepStep(wfstep.getWfstepStepEdit());
        wfstep.setWfstepAssignedTo(wfstep.getWfstepAssignedToEdit());
        wfstep.setWfstepName(wfstep.getWfstepNameEdit());
        wfstep.setWfstepType(wfstep.getWfstepTypeEdit());
        wfstep.setWfstepCreatedBy(wfstep.getWfstepCreatedByEdit());
        wfstep.setWfstepCreatedDate(wfstep.getWfstepCreatedDateEdit());
        HttpSession sess = request.getSession();

        Calendar currentDate = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String updatedDate = formatter.format(currentDate.getTime());

        wfstep.setWfstepUpdatedBy(sess.getAttribute("userId").toString());

        wfstep.setWfstepUpdatedDate(updatedDate);

        String msg = wfstepService.updateWFStep(wfstep);

        if (msg.equals("S")) {
          request.setAttribute(
              "wfstepUpadteSuccess", "Work Flow Step has been updated Successfully");
        } else {
          request.setAttribute("wfstepUpadteFail", "Work Flow Step has not been updated");
        }
      } else {
        request.setAttribute("wfstepEditDuplicate", "Name Already Exists");
        request.setAttribute("wfstepValues", "wfstepValues");
        return "wfstepHome";
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    model.addAttribute("wfstepAdd", new WFStep());
    /* return new ModelAndView("Home","materialAdd",new Material()); */
    return "wfstepHome";
  }
  @RequestMapping(value = "/wfstepAdd", method = RequestMethod.GET)
  @RequestScoped
  public String saveWFStepDetails(
      @ModelAttribute("wfstepAdd") @Valid WFStep wfstep,
      BindingResult result,
      DefaultSessionAttributeStore store,
      WebRequest request1,
      HttpServletRequest request,
      SessionStatus status,
      Model model,
      HttpServletResponse response) {
    sess = request.getSession(false);
    Calendar currentDate = Calendar.getInstance();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    String createdDate = formatter.format(currentDate.getTime());
    wfstep.setWfstepCreatedBy(sess.getAttribute("userId").toString());
    wfstep.setWfstepCreatedDate(createdDate);

    String msg = null;
    String res = null;
    String wfStepSave = null;

    Long duplicateId = 0l;

    try {
      // here we set the CharacterEncoding to resonse becoz of
      // Localization Concept

      // this method is used to check the Duplicates
      String sid = wfstep.getWfstepStageGUID();
      System.out.println("stagename" + sid);
      String stepName = wfstep.getWfstepName();

      duplicateId = wfstepService.duplicateWFStepCheck(sid, stepName);
      if (duplicateId == 0) {
        // here there are no duplicates
        // saveRoleDetails this method is used to save Role Details

        msg =
            wfstepService.saveWFStepDetails(
                wfstep,
                sess.getAttribute("userId").toString(),
                sess.getAttribute("userName").toString());
        model.addAttribute("wfstepAdd", new WFStep());
        if (msg.equals("S")) {

          res = "redirect:wfstepHome.mnt?list=" + "success" + "";

        } else {

          res = "redirect:wfstepHome.mnt?listwar=" + "fail" + "";
        }
      } else {

        request.setAttribute("WFStepDuplicate", "WFStep Name");
        wfstep.setAid(1);
        return "wfstepHome";
      }

    } catch (Exception e) {

      res = "redirect:wfstepHome.mnt?listwar=" + "fail" + "";
      e.printStackTrace();
    }
    return res;
  }