Пример #1
0
  Object onDelete(String courseUuid) {
    if (!StudentUtil.isPossibleUuid(courseUuid)) {
      LOG.info("Invalid CourseUUID");
      courseUuid = null;
      course = null;
      return this;
    }

    this.courseUuid = courseUuid;
    int courseVersion = 0;

    try {
      courseManagerService.deleteCourse(courseUuid, courseVersion);
    } catch (ObjectNotFoundException e) {
      // object has already been deleted.
      LOG.trace("course not found: " + courseUuid);
    } catch (RestClientFailureException e) {
      createForm.recordError("Internal error on server.");
      createForm.recordError(e.getMessage());

      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      deleteMessage = ExceptionUtil.getRootCauseMessage(e);

      // Trigger new event "failedDelete" which will bubble up.
      componentResources.triggerEvent(FAILED_DELETE, new Object[] {courseUuid}, null);
      // We don't want "delete" to bubble up, so we return true to say
      // we've handled it.
      // TODO: replace with exception service
      LOG.debug("internal error on server during validation", e);
      return true;
    } catch (Exception e) {
      // Display the cause. In a real system we would try harder to get a
      // user-friendly message.
      deleteMessage = ExceptionUtil.getRootCauseMessage(e);

      // Trigger new event "failedDelete" which will bubble up.
      componentResources.triggerEvent(FAILED_DELETE, new Object[] {courseUuid}, null);
      // We don't want "delete" to bubble up, so we return true to say
      // we've handled it.
      // TODO: replace with exception service
      LOG.info("unhandled exception during deletion", e);
      return true;
    }

    // Trigger new event "successfulDelete" which will bubble up.
    componentResources.triggerEvent(SUCCESFUL_DELETE, new Object[] {courseUuid}, null);
    // We don't want "delete" to bubble up, so we return true to say we've
    // handled it.
    return indexPage;
  }
Пример #2
0
  /**
   * Event method in order to get the datas to display.
   *
   * @throws IOException
   */
  @OnEvent(value = JQueryEventConstants.DATA)
  JSONObject onData() throws IOException {
    /**
     * If ajax mode, we filter on server-side, otherwise, we filter from the available data already
     * loaded (see DefaultDataTableModel#filterData)
     */
    if (getMode()) {
      /** Give a chance to the developer to update the GridDataSource to filter data server-side */
      resources.triggerEvent(JQueryEventConstants.FILTER_DATA, null, null);
      /** Give a chance to the developer to sort the GridDataSource server-side */
      resources.triggerEvent(JQueryEventConstants.SORT_DATA, null, null);
    }

    return getDataTModel()
        .sendResponse(
            request, getSource(), getDataModel(), getSortModel(), getOverrides(), getMode());
  }
Пример #3
0
 boolean onFailureFromCreateForm() {
   // Rather than letting "failure" bubble up which doesn't say what you
   // were trying to do, we trigger new event
   // "failedCreate". It will bubble up because we don't have a handler
   // method for it.
   componentResources.triggerEvent(FAILED_CREATE, null, null);
   // We don't want "failure" to bubble up, so we return true to say we've
   // handled it.
   return true;
 }
Пример #4
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;
  }
Пример #5
0
  boolean onSuccessFromUpdateForm() {
    // We want to tell our containing page explicitly what course we've
    // updated, so we trigger new event
    // "successfulUpdate" with a parameter. It will bubble up because we
    // don't have a handler method for it.
    componentResources.triggerEvent(SUCCESSFUL_UPDATE, new Object[] {courseUuid}, null);

    // We don't want "success" to bubble up, so we return true to say we've
    // handled it.
    mode = Mode.REVIEW;
    return true;
  }