Last updated by rhyolight
4 years ago
Commentable Plugin
This plugin provides a generic way to add and manage comments for a given applicationRequirements
- Grails Version: 1.1 and above
- JDK: 1.5 and above
Installation
grails install-plugin commentable
Usage
Implement theCommentable interface:import org.grails.comments.*class Vehicle implements Commentable { }
def user = User.get(1) def v = Vehicle.get(1)v.addComment(user, "I prefer red cars") .addComment(user, "I prefer sporty cars")
def v = Vehicle.get(1)
v.comments.each { println it.body }<comments:each bean="${vehicle}">
${comment.body} - Posted by ${comment.poster}
</comments:each>grails.commentable.poster.evaluator = { request.user }grails.commentable.poster.evaluator = { session.user }<comments:render> tag to render all comments with a comment editor:<comments:render bean="${vehicle}" />class MyThing implements Commentable { String name def onAddComment = { comment -> // post processing logic for newly added comment } }