Package springblog.pojo

Examples of springblog.pojo.Comment


  private CommentManager commentManager = null;
 
 
  @RequestMapping(value = {"/comment/{commentID}/delete"})
  public String deleteComment(@PathVariable int commentID, Model model) {
    Comment comment = commentManager.getCommentByID(commentID);
    if (null == comment) {
      model.addAttribute("message", "No such comment.");
      return "message";
    }
    commentManager.delete(comment);
    return "redirect:/article/" + comment.getArticleID();
  }
View Full Code Here


 
  @Override
  public Comment getCommentByID(int commentID) {
    String sql = "select * from Comment where id = ? ";
    try {
      Comment comment = jdbcTemplate.queryForObject(sql, new CommentRowMapper(), commentID);
      return comment;
    } catch (EmptyResultDataAccessException e) {
      return null;
    }
  }
View Full Code Here

class CommentRowMapper implements RowMapper<Comment> {

  @Override
  public Comment mapRow(ResultSet rs, int numRow) throws SQLException {
    Comment comment = new Comment();
    comment.setId(rs.getInt("id"));
    comment.setArticleID(rs.getInt("articleID"));
    comment.setAuthor(rs.getString("author"));
    comment.setText(rs.getString("text"));
    comment.setDateCreated(rs.getString("dateCreated"));
    return comment;
  }
View Full Code Here

  public String addComment(@PathVariable int commentArticleID, Model model) {
    if (null == articleManager.getArticleByID(commentArticleID)) {
      model.addAttribute("message", "Cannot add comment for a non-existing article.");
      return "message";
    }
    Comment comment = new Comment();
    comment.setArticleID(commentArticleID);
    model.addAttribute("comment", comment);
    return "comment-form";
  }
View Full Code Here

  }
 
 
  @RequestMapping(value = {"/comment/{commentID}/edit"}, method = RequestMethod.GET)
  public String editComment(@PathVariable int commentID, Model model) {
    Comment comment = commentManager.getCommentByID(commentID);
    if (null == comment) {
      model.addAttribute("message", "No such comment.");
      return "message";
    }
    model.addAttribute("comment", comment);
View Full Code Here

TOP

Related Classes of springblog.pojo.Comment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.