コード例 #1
0
 @Before
 public void setupSignup() {
   signupForm = new SignupForm();
   signupForm.setId((long) 1500);
   signupForm.setFirstName("Capitain");
   signupForm.setLastName("Awesome");
   signupForm.setEmail("*****@*****.**");
   signupForm.setBiography("I try to be .......... awesome...");
   signupForm.setPassword("123456");
   signupForm.setTimeSlots(getNewTimeSlotList());
   signupForm.setUserCourseList(getNewUserCourseFormAttributeList());
 }
コード例 #2
0
  /**
   * Serve model with signupForm.
   *
   * @param principal the logged in principal.
   * @return a signupForm with filled name and biography fields.
   */
  @ModelAttribute("signupForm")
  public SignupForm getSignupForm(Principal principal) {
    User user = userService.getPrincipalUser();

    SignupForm form = new SignupForm();
    form.setFirstName(user.getFirstName());
    form.setLastName(user.getLastName());
    form.setBiography(user.getBiography());

    try {
      AutoPopulatingList<UserCourseFormAttribute> userCourseList =
          new AutoPopulatingList<UserCourseFormAttribute>(new UserCourseFormAttributeFactory());
      Iterator<UserCourse> itr = userCourseDao.findByUser(user).iterator();
      while (itr.hasNext()) {
        UserCourse tmpUserCourse = itr.next();
        UserCourseFormAttribute formAttr = new UserCourseFormAttribute();
        formAttr.setUniversity(tmpUserCourse.getCourse().getSubject().getUniversity().toString());
        formAttr.setSubject(tmpUserCourse.getCourse().getSubject().toString());
        formAttr.setCourse(tmpUserCourse.getCourse().toString());
        formAttr.setGrade(String.valueOf(tmpUserCourse.getGrade()));
        formAttr.setTeaching(tmpUserCourse.isTeaching());
        userCourseList.add(formAttr);
      }
      form.setUserCourseList(userCourseList);
    } catch (Exception e) {
    }

    try {
      AutoPopulatingList<TimeSlot> timeSlotList =
          new AutoPopulatingList<TimeSlot>(new TimeSlotFactory());
      ListIterator<TimeSlot> iter = user.getTimeSlots().listIterator();
      while (iter.hasNext()) {
        timeSlotList.add(iter.next());
      }
      form.setTimeSlots(timeSlotList);
    } catch (Exception e) {
    }

    return form;
  }