Ejemplo n.º 1
0
  public String topicsdelete() {
    String delTopicId = this.request.getParameter("topicid");
    System.out.println("topicid=" + delTopicId);
    List<Comment> topiccomments = new ArrayList<Comment>();

    if (delTopicId != null && delTopicId.length() > 0) {
      try {
        topiccomments = bm.loadCommentsByTopicId(Integer.parseInt(delTopicId));
      } catch (NumberFormatException e) {
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (SQLException e) {
        e.printStackTrace();
      }

      for (Comment comm : topiccomments) {
        System.out.println("$$$---" + comm.toString());
        try {
          bm.delete(comm);
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }

      Topic deltopic = new Topic();
      deltopic.setId(Integer.parseInt(delTopicId));
      try {
        bm.delete(deltopic);
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
    this.listAllTopics();
    return "delete";
  }