コード例 #1
1
  /**
   * Deletes a meeting from the database
   *
   * <p>- Requires a cookie for the session user - Requires a meetingId request parameter for the
   * HTTP GET
   *
   * @param req The HTTP Request
   * @param res The HTTP Response
   */
  public void deletemeetingAction(HttpServletRequest req, HttpServletResponse res) {
    // Ensure there is a cookie for the session user
    if (AccountController.redirectIfNoCookie(req, res)) return;

    if (req.getMethod() == HttpMethod.Get) {

      // Get the meeting
      int meetingId = Integer.parseInt(req.getParameter("meetingId"));
      MeetingManager meetingMan = new MeetingManager();
      Meeting meeting = meetingMan.get(meetingId);
      meetingMan.deleteMeeting(meetingId);

      // Update the User Session to remove meeting
      HttpSession session = req.getSession();
      Session userSession = (Session) session.getAttribute("userSession");
      List<Meeting> adminMeetings = userSession.getUser().getMeetings();

      for (int i = 0; i < adminMeetings.size(); i++) {
        Meeting m = adminMeetings.get(i);
        if (m.getId() == meeting.getId()) {
          adminMeetings.remove(i);
          break;
        }
      }

      redirectToLocal(req, res, "/home/dashboard");
      return;

    } else if (req.getMethod() == HttpMethod.Post) {
      httpNotFound(req, res);
    }
  }
コード例 #2
0
 /**
  * Move a table column from its original position to a new position.
  *
  * <p>The table expands automatically when the <code>to</code> column is beyond the current table
  * dimensions.
  *
  * <p>
  *
  * @see WTable#moveRow(int from, int to)
  */
 public void moveColumn(int from, int to) {
   if (from < 0 || from >= (int) this.columns_.size()) {
     logger.error(
         new StringWriter()
             .append("moveColumn: the from index is not a valid column index.")
             .toString());
     return;
   }
   WTableColumn from_tc = this.getColumnAt(from);
   this.columns_.remove(from_tc);
   if (to > (int) this.columns_.size()) {
     this.getColumnAt(to);
   }
   this.columns_.add(0 + to, from_tc);
   for (int i = 0; i < this.rows_.size(); i++) {
     List<WTableRow.TableData> cells = this.rows_.get(i).cells_;
     WTableRow.TableData cell = cells.get(from);
     cells.remove(0 + from);
     cells.add(0 + to, cell);
   }
   this.flags_.set(BIT_GRID_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }