Esempio n. 1
0
  /** Contains Display Logic */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    HttpSession session = request.getSession(true);
    UserModel sessionModel = (UserModel) session.getAttribute("user");

    Long id = sessionModel.getCollegeId();
    Long roleId = sessionModel.getRoleId();

    if (id == 0) {
      id = DataUtility.getLong(request.getParameter("id"));
    }

    CollegeModel model = new CollegeModel();
    System.out.println("org12" + UserFilterManager.getOrganizationId(request));
    model.setOrganizationId(UserFilterManager.getOrganizationId(request));

    if (id > 0) {
      try {
        model = model.findByPK(id);
        ServletUtility.setModel(model, request);
      } catch (ApplicationException e) {
        ServletUtility.handleException(e, request, response);
        return;
      }
    }
    ServletUtility.setModel(model, request);
    ServletUtility.forwardView(ORSView.COLLEGE_VIEW, request, response);
  }
Esempio n. 2
0
  /** Validates Input data */
  @Override
  protected boolean validate(HttpServletRequest request) {

    log.debug("UserCtl Method validate Started");

    boolean pass = true;

    String login = request.getParameter("login");
    String dob = request.getParameter("dob");

    if (DataValidator.isNull(request.getParameter("firstName"))) {
      request.setAttribute("firstName", PropertyReader.getValue("error.require", "First Name"));
      pass = false;
    }

    if (DataValidator.isNull(request.getParameter("lastName"))) {
      request.setAttribute("lastName", PropertyReader.getValue("error.require", "Last Name"));
      pass = false;
    }

    if (DataValidator.isNull(login)) {
      request.setAttribute("login", PropertyReader.getValue("error.require", "Login Id"));
      pass = false;
    } else if (!DataValidator.isEmail(login)) {
      request.setAttribute("login", PropertyReader.getValue("error.email", "Login "));
      pass = false;
    }

    if (DataValidator.isNull(request.getParameter("password"))) {
      request.setAttribute("password", PropertyReader.getValue("error.require", "Password"));
      pass = false;
    }

    if (DataValidator.isNull(request.getParameter("confirmPassword"))) {
      request.setAttribute(
          "confirmPassword", PropertyReader.getValue("error.require", "Confirm Password"));
      pass = false;
    }

    if (DataValidator.isNull(request.getParameter("gender"))) {
      request.setAttribute("gender", PropertyReader.getValue("error.require", "Gender"));
      pass = false;
    }
    if (DataValidator.isNull(dob)) {
      request.setAttribute("dob", PropertyReader.getValue("error.require", "Date Of Birth"));
      pass = false;
    } else if (!DataValidator.isDate(dob)) {
      request.setAttribute("dob", PropertyReader.getValue("error.date", "Date Of Birth"));
      pass = false;
    }
    if (!request.getParameter("password").equals(request.getParameter("confirmPassword"))
        && !"".equals(request.getParameter("confirmPassword"))) {
      ServletUtility.setErrorMessage("Confirm  Password  should not be matched.", request);
      pass = false;
    }

    log.debug("UserCtl Method validate Ended");

    return pass;
  }
Esempio n. 3
0
  /** Contains Display Logic */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Long id = DataUtility.getLong(request.getParameter("id"));

    UserModel model = new UserModel();

    if (id > 0) {
      try {
        model = model.findByPK(id);
        ServletUtility.setModel(model, request);
      } catch (ApplicationException e) {
        ServletUtility.handleException(e, request, response);
        return;
      }
    }
    ServletUtility.forwardView(ORSView.USER_VIEW, request, response);
  }
Esempio n. 4
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    log.debug("UserCtl Method doPost Started");
    String op = DataUtility.getString(request.getParameter("operation"));

    // get model
    UserModel model = (UserModel) populateModel(request);

    long id = model.getId();

    if (OP_SAVE.equalsIgnoreCase(op)) {
      try {
        if (id > 0) {
          model.update();

        } else {
          long pk = model.add();
          model.setId(pk);
        }
        ServletUtility.setModel(model, request);
        ServletUtility.setSuccessMessage("Data is successfully saved", request);
      } catch (ApplicationException e) {
        log.error(e);
        ServletUtility.handleException(e, request, response);
        return;
      }

    } else if (OP_DELETE.equalsIgnoreCase(op)) {
      try {
        model.delete();
        ServletUtility.redirect(ORSView.USER_LIST_CTL, request, response);
        return;
      } catch (ApplicationException e) {
        log.error(e);
        ServletUtility.handleException(e, request, response);
        return;
      }
    } else {
      if (id > 0 || op != null) {
        UserModel model1;
        try {
          model1 = model.findByPK(id);
          ServletUtility.setModel(model1, request);
        } catch (ApplicationException e) {

          ServletUtility.handleException(e, request, response);
          return;
        }
      }
    }
    ServletUtility.forwardView(ORSView.USER_VIEW, request, response);
    log.debug("UserCtl Method doPost Ended");
  }