Esempio n. 1
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");
  }
Esempio n. 2
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);
  }