Пример #1
0
  void onValidateFromCreateForm() {

    if (createForm.getHasErrors()) {
      // We get here only if a server-side validator detected an error.
      return;
    }

    try {
      course =
          courseManagerService.createCourse(
              course.getCode(), course.getName(), course.getSummary(), course.getDescription(), 1);
    } catch (RestClientFailureException e) {
      createForm.recordError("Internal error on server.");
      createForm.recordError(e.getMessage());
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
    } catch (Exception e) {
      createForm.recordError(ExceptionUtil.getRootCauseMessage(e));
      // TODO: replace with exception service
      LOG.info("unhandled exception during validation", e);
    }
  }
Пример #2
0
  void onValidateFromUpdateForm() {

    if (updateForm.getHasErrors()) {
      // We get here only if a server-side validator detected an error.
      return;
    }

    try {
      courseManagerService.updateCourse(
          course, course.getName(), course.getSummary(), course.getDescription(), 1);
    } catch (RestClientFailureException e) {
      updateForm.recordError("Internal error on server.");
      updateForm.recordError(e.getMessage());
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
    } catch (Exception e) {
      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      updateForm.recordError(ExceptionUtil.getRootCauseMessage(e));
      // TODO: replace with exception service
      LOG.info("unhandled exception during validation", e);
    }
  }
Пример #3
0
  void onPrepareForRenderFromUpdateForm() {
    if (!StudentUtil.isPossibleUuid(courseUuid)) {
      LOG.info("Invalid CourseUUID");
      courseUuid = null;
      course = null;
    } else {
      try {
        course = courseFinderService.findCourseByUuid(courseUuid);
      } catch (ObjectNotFoundException e) {
        // Handle null course in the template.
        LOG.trace("course not found: " + courseUuid);
      }
    }

    // If the form has errors then we're redisplaying after a redirect.
    // Form will restore your input values but it's up to us to restore
    // Hidden values.

    if (updateForm.getHasErrors()) {
      if (course != null) {
        course.setVersion(versionFlash);
      }
    }
  }