Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Mohammed-Skouti, You can try below code snippet; it's working fine for me.
Node collectionNode;
if (assetNode.hasNode("jcr:content/comments")) {
collectionNode = assetNode.getNode("jcr:content/comments");
} else {
collectionNode = assetNode.addNode("jcr:content/comments");
collectionNode.setPrimaryType("nt:unstructured");
collectionNode.addMixin( "mix:lastModified");
collectionNode.setProperty(
"sling:resourceType", "granite/comments/components/collection");
}
Node commentNode = collectionNode.addNode("customComment");
commentNode.setPrimaryType("nt:unstructured");
commentNode.addMixin( "mix:lastModified");
commentNode.setProperty("sling:resourceType", "granite/comments/components/comment");
commentNode.setProperty("jcr:description", "Your Comment Here");
session.save();
Hi @Mohammed-Skouti, You can try below code snippet; it's working fine for me.
Node collectionNode;
if (assetNode.hasNode("jcr:content/comments")) {
collectionNode = assetNode.getNode("jcr:content/comments");
} else {
collectionNode = assetNode.addNode("jcr:content/comments");
collectionNode.setPrimaryType("nt:unstructured");
collectionNode.addMixin( "mix:lastModified");
collectionNode.setProperty(
"sling:resourceType", "granite/comments/components/collection");
}
Node commentNode = collectionNode.addNode("customComment");
commentNode.setPrimaryType("nt:unstructured");
commentNode.addMixin( "mix:lastModified");
commentNode.setProperty("sling:resourceType", "granite/comments/components/comment");
commentNode.setProperty("jcr:description", "Your Comment Here");
session.save();
@Mohammed-Skouti Did you find the suggestion from Mahedi helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies