Exemplo n.º 1
0
  private void constituteTopic(int _topicid) {
    try {
      this.topic = bm.loadTopicWithCommentsByTopicId(_topicid);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    User u = new User();
    try {
      u = um.loadUserByid(this.topic.getAuther());
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    this.topic.setUser(u);

    for (Comment comm : this.topic.getComments()) {
      User cu = new User();
      try {
        cu = um.loadUserByid(comm.getAuther());
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (SQLException e) {
        e.printStackTrace();
      }
      comm.setUser(cu);
      System.out.println("cu---" + cu.toString());
      System.out.println("Comm---" + comm.toString());
      System.out.println("Commuser---" + comm.getUser().toString());
    }
  }
Exemplo n.º 2
0
  public String commentsave() {

    System.out.println("--------------commentsave-----------");
    User u = new User();
    u = (User) this.request.getSession().getAttribute("user_");
    System.out.println("User------" + u.toString());

    String content = this.binfo.getCommentcontent();
    String topicid = this.binfo.getId();
    this.comment = new Comment();
    this.comment.setContent(content);
    this.comment.setTopicid(Integer.parseInt(topicid));
    this.comment.setAuther(u.getId());
    this.comment.setUser(u);
    this.comment.setDate(CONSTANT.getNowTime());
    System.out.println("this.comment----" + this.comment.toString());
    try {
      bm.add(this.comment);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    this.constituteTopic(this.comment.getTopicid());
    this.updateTopicTime(this.comment.getTopicid(), this.comment.getDate());
    return "save";
  }
Exemplo n.º 3
0
  public String topicbuilt() {
    System.out.println("--------------topicbuilt-----------");
    User u = new User();
    u = (User) this.request.getSession().getAttribute("user_");

    this.topic = new Topic();
    this.topic.setTitle(this.binfo.getTopictitle());
    this.topic.setContent(this.binfo.getTopiccontent());
    this.topic.setDate(CONSTANT.getNowTime());
    this.topic.setAuther(u.getId());
    this.topic.setAuthername(u.getUsername());
    this.topic.setLastupdate(this.topic.getDate());
    System.out.println("topic---------------" + this.topic.toString());
    try {
      bm.add(this.topic);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    this.alltopiclist();
    return "built";
  }