Exemple #1
0
 boolean onSuccessFromCreateForm() {
   // We want to tell our containing page explicitly what course we've
   // created, so we trigger new event
   // "successfulCreate" with a parameter. It will bubble up because we
   // don't have a handler method for it.
   componentResources.triggerEvent(SUCCESSFUL_CREATE, new Object[] {course.getUuid()}, null);
   // We don't want "success" to bubble up, so we return true to say we've
   // handled it.
   mode = Mode.REVIEW;
   courseUuid = course.getUuid();
   return true;
 }
Exemple #2
0
  boolean onFailureFromUpdateForm() {
    versionFlash = course.getVersion();

    // Rather than letting "failure" bubble up which doesn't say what you
    // were trying to do, we trigger new event
    // "failedUpdate". It will bubble up because we don't have a handler
    // method for it.
    componentResources.triggerEvent(FAILED_UPDATE, new Object[] {courseUuid}, null);
    // We don't want "failure" to bubble up, so we return true to say we've
    // handled it.
    return true;
  }
Exemple #3
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);
    }
  }
Exemple #4
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);
    }
  }
Exemple #5
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);
      }
    }
  }