Fork me on GitHub

Developer's How-to (Document Commenting Plugin)

Configuring 'Comments' Field in Document Template

In a document type definition (a.k.a. namespace configuration), you should add a custom field under editor:templates/_default_ node like the following example (document-commenting node) in yaml format:

/document-commenting:
jcr:primaryType: frontend:plugin
caption: Comments
comment.deletable.author.only: false
comment.editable.author.only: false
comment.persistence.manager: org.onehippo.forge.document.commenting.cms.impl.DefaultJcrCommentPersistenceManager
comment.query.limit: 100
dialog.size: width=600,height=400
engine: ${engine}
mode: ${mode}
plugin.class: org.onehippo.forge.document.commenting.cms.impl.DefaultDocumentCommentingFieldPlugin
selection.mode: multiple
wicket.id: ${cluster.id}.right.item
wicket.model: ${wicket.model}
/cluster.options:
  jcr:primaryType: frontend:pluginconfig
  jcr.comment.persistence.date.format: yyyy-MM-dd HH:mm:ss
  jcr.comment.persistence.query: //element(*,doccommenting:commentdata)[@doccommenting:subjectid=''{0}'']
    order by @doccommenting:created descending
      

See the following for a full example in the demo project: https://github.com/bloomreach-forge/document-commenting/blob/master/demo/repository-data/config/src/main/resources/hcm-config/namespaces/doccommentingdemo/newsdocument.yaml

Implementing your own CommentPersistenceManager service

The Document Commenting plugin actually doesn't store/read data by itself, but relies on a CommentPersistenceManager service implementation specified in the plugin configuration as shown above. Therefore, you may extend the default implementation or you can replace it with a totally new implementation to support a different comment data storage (e.g, NoSQL database) for instance.

See an example CommentPersistenceManager implementation code here: https://github.com/bloomreach-forge/document-commenting/blob/master/demo/cms/src/main/java/org/onehippo/forge/document/commenting/demo/cms/CustomPrioritizingJcrCommentPersistenceManager.java

The example custom service implementation is used in the 'event' document namespace for demonstration purpose in the demo project.

Put your own implementation class in your CMS module project.

See Javadocs for detail about the CommentPersistenceManager.

Plugin Parameters

You may configure the following plugin parameters in the field definition of your document template definition (a.k.a 'namespace').

Parameter name Description Example value(s) Default value(s)
caption Field caption, used as field label and dialog title. "Remarks" "Comments"
comment.persistence.manager org.onehippo.forge.document.commenting.cms.api.CommentPersistenceManager implementation class FQN. "org.onehippo.forge.document.commenting.cms.impl.DefaultJcrCommentPersistenceManager"
comment.query.limit The JCR query limit when retrieving the latest comment data by subject ID. 20 100
dialog.size The size of the picker popup dialog. "width=500,height=350" "width=600,height=400"
comment.editable.author.only Whether or not each comment can be edited only by the original comment author. true false
comment.deletable.author.only Whether or not each comment can be deleted only by the original comment author. true false

Parameters of DefaultJcrCommentPersistenceManager

The following parameters are set for the DefaultJcrCommentPersistenceManager implementation additionally (under cluster.options node).

Parameter name Description Example value(s) Default value(s)
jcr.comment.persistence.query The JCR XPath query used when retrieving the latest comment data in the field area. //element(*,doccommenting:commentdata)[@doccommenting:subjectid=''{0}''] order by @doccommenting:lastModified descending //element(*,doccommenting:commentdata)[@doccommenting:subjectid=''{0}''] order by @doccommenting:created descending
jcr.comment.persistence.date.format The date format string to display MM/dd/yyyy HH:mm:ss yyyy-MM-dd HH:mm:ss