Example #1
0
  /** This method is used to retrieve data and show it on the screen */
  public void render() {
    jLabelName.setText(this.subscription.getTitle());
    jLabelGender.setText("Man");
    jLabelAge.setText(String.valueOf(this.subscription.getMinimumAge()));
    jLabelDays.setText(CourseInfo.implode(this.subscription.getDays(), ", "));
    jLabelDuration.setText(
        String.valueOf(this.subscription.getStartTime())
            + " - "
            + String.valueOf(this.subscription.getEndTime()));
    jLabelDescription.setText(this.subscription.getDescription());
    jLabelBranch.setText(this.subscription.getBranch().getCity());

    // Empty results
    jLabelUser.setText("");
    jBtnSubmit.setVisible(false);

    // Age range
    if (this.subscription.getMaximumAge() <= 16) jLabelAge.setText("< 16");
    else if (this.subscription.getMaximumAge() <= 18) jLabelAge.setText("16 - 18");
    else if (this.subscription.getMaximumAge() <= 65) jLabelAge.setText("18 - 65");
    else if (this.subscription.getMaximumAge() <= 150) jLabelAge.setText("65+");

    // Enrollments
    ArrayList<User> users = Enrollment.readBySubscriptionId(this.subscription.getId());

    for (User user : users) {
      if (user.getFullName() != "" && user.getFirstname() != null) {
        this.model.insertRow(0, new Object[] {user.getId(), user.getFullName()});
      }
    }

    // Make a selection listener
    this.row = jTableUsers.getSelectionModel();
    this.row.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  }
Example #2
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   * @throws ServletException if a servlet-specific error occurs
   * @throws IOException if an I/O error occurs
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    HttpSession session = request.getSession(false);
    User u = (User) session.getAttribute("user");

    request.setAttribute("name", u.getFirstname() + " " + u.getLastname());
    request.setAttribute("profilepic", u.getProfilePIC());
    getServletContext().getRequestDispatcher("/tools.jsp").forward(request, response);
  }