示例#1
0
  @Override
  protected BaseModel populateModel(HttpServletRequest request) {

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

    UserModel model = new UserModel();

    model.setId(DataUtility.getLong(request.getParameter("id")));

    model.setRoleId(DataUtility.getLong(request.getParameter("roleId")));

    model.setFirstName(DataUtility.getString(request.getParameter("firstName")));

    model.setLastName(DataUtility.getString(request.getParameter("lastName")));

    model.setLogin(DataUtility.getString(request.getParameter("login")));

    model.setPassword(DataUtility.getString(request.getParameter("password")));

    model.setConfirmPassword(DataUtility.getString(request.getParameter("confirmPassword")));

    model.setGender(DataUtility.getString(request.getParameter("gender")));

    model.setDob(DataUtility.getDate(request.getParameter("dob")));

    populateModel(model, request);

    System.out.println(model.getFirstName());

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

    return model;
  }
示例#2
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");
  }