예제 #1
0
 @RequestMapping(value = "/register_Teacher", method = RequestMethod.POST)
 public ModelAndView studentsPage(
     @ModelAttribute Teacher teacher, @ModelAttribute Login login, String birthday)
     throws ParseException {
   Date birthdate = new SimpleDateFormat("yyyy-mm-dd").parse(birthday);
   teacher.setBday(birthdate);
   homeService.registerTeacher(teacher);
   homeService.loginCredentials(login);
   return new ModelAndView("dashboard");
 }
예제 #2
0
  @RequestMapping(value = "/teacher/manageTeacher", headers = "Accept=application/json")
  @ResponseBody
  public String manageTeachers() {
    List<Teacher> result = homeService.findallTeachers();
    JSONObject json = new JSONObject();
    json.put("Result", "OK");

    for (int i = 0; i < result.size(); i++) {
      System.out.println("Value: " + i + " - Person ID: " + result.get(i).getUserId());
      JSONObject teacherObj = new JSONObject();
      teacherObj.put("userId", result.get(i).getUserId());
      teacherObj.put("fname", result.get(i).getFname());
      teacherObj.put("lname", result.get(i).getLname());
      teacherObj.put("mname", result.get(i).getMname());
      teacherObj.put("address", result.get(i).getAddress());
      teacherObj.put("bday", result.get(i).getBday().toString());
      teacherObj.put("gender", result.get(i).getGender());
      teacherObj.put("email", result.get(i).getEmail());
      json.accumulate("Records", teacherObj);
    }

    System.out.println("JSON: " + json.toString(2));
    String jsonString = json.toString();
    return jsonString;
  }
예제 #3
0
  @RequestMapping(value = "/teacher/updateTeacher", headers = "Accept=application/json")
  @ResponseBody
  public void updateTeacher(
      @ModelAttribute TeacherForm teacherForm, BindingResult result, String bday)
      throws ParseException {
    if (result.hasErrors()) {
      logger.info("\nERROOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOR ");
      logger.info("\nDATE : " + bday);
      Date birthdate = new SimpleDateFormat("yyyy-mm-dd").parse(bday);
      teacherForm.setBday(birthdate);
      logger.info("\nDATE after set :" + teacherForm.getBday());
    }

    // Date birthdate = new SimpleDateFormat("yyyy-mm-dd").parse(bday);
    // teacherForm.setBday(birthdate);
    homeService.updateTeacher(teacherForm);
  }