示例#1
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";
  }
示例#2
0
 private void sortTopiclistByDate(List<Topic> _list) {
   List<String> toSort = new ArrayList<String>();
   for (Topic topic : _list) {
     if (topic.getLastupdate() != null && topic.getLastupdate().length() >= 10)
       toSort.add(topic.getLastupdate());
     else {
       topic.setLastupdate(topic.getDate());
       toSort.add(topic.getLastupdate());
     }
   }
   List<Integer> seqs = new ArrayList<Integer>();
   seqs = CONSTANT.sortDatesDesc(toSort);
   List<Topic> sortedTopiclist = new ArrayList<Topic>();
   for (Integer seq : seqs) sortedTopiclist.add(_list.get(seq));
   this.setTopiclist(sortedTopiclist);
 }
示例#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";
  }