In the old days you a typical commenting feature was something with a form and a view. Typically you could read a list of comments in a historical (flat) order and on the bottom you had the form to enter your comment. Something like in the IBM Domino blog template.
With the rise of social and mobile it became more important to be able to comment-only so the form moved to the top and the list of comments became sorted in the opposite order (Youtube).
Discussions are still displayed in a thread but since threads are less friendly on a mobile device a more what’app like chat display. But these are more instant messaging apps, similar to Slack or IBM’s upcoming Toscana.
My idea: welcome to the bubble
So what can/should we do to modernize the display of the comment feature in our Notes/XPages application?
Well mainly we still have a top level object (TLO) where people comment on. To stimulate people to comment the form should be close to this TLO. We can promote the interaction between a user and others and provide some form of “bubble speech” experience and (ofcourse) the option to “like” a comment.
That would bring us to something more like this:
Notice on the left you see the comments I have made and on the right comments made by others. The latest comment is displayed first and mines are a bit more outstanding using a background-color.
Now how it’s made
To come to this solutions I am using the following technologies:
Note that in a previous post I described how to add @mention autocomplete like Facebook, Twitter & Google+ to your XPages app. So I will not discuss in this post how to build the form to comment.
Here is a general outline of what we are going to build:
Step 1 – basic structure; a repeater with a panel
First I have a repeat control which is bound to an ArrayList containing JsonObjects. This approach you can find in my Bildr project on OpenNTF (shameless plug).
I also added an infinite scroll function. You can read about how to set that up in this post.
The panel has a computed styleclass. The style defintion “right” does nothing more than a text-align: right. This makes sure the text in the content is … aligned right.
Step 2 – adding a user icon
Humans are visually oriented and idle so nothing wrong making our display attractive with a user icon.
In this example I am just displaying some random icons, but if you have a corporate directory with user profiles containing icons you should embed them here.
The pull-left and pull-right classes are from Bootstrap. My comments are pulled to the left, comments from others to the right.
Step 3 – the media body
Next item that we add is a div with a media-body class. It contains out of 2 sections: the content of the comment (text written) and some meta-data (date, author). I also added a “like” link which is inspired by Thomas Adrian’s Intrapages app also available on OpenNTF.
(Guess I don’t need the attributes here…). Here is the part of the meta-data:
First I display the Author name, only for comments written by others. In order to make the date more human friendly to read I am using PrettyTime. In the past I have blogged about how to use it.
For the remove link I am using the userbean to check if I can delete documents in the database and if the comment is mine: (@UserName() == obj.From) && (userBean.canDeleteDocs == true)
For the event I check and ask if I am sure that I want to remove the entry and then I simply remove it by UNID:
For the “like” button I would like to point to Adrian’s example in his Intrapages project. I made however the exeption to store the likes in a separate document, so not in the comment. By this way I can tighten my security model. Everybody has the role of [liker] and author access. So everybody can update a like document and not the original comment document.
The like function uses the cookie management principles described here. It stores the username:
userCookie = new javax.servlet.http.Cookie(“userid”, @UserName());
I have set the duration of the cookie as long as the session is active:
//Cookie.setMaxAge(-1) will make the cookie expire after the browser is closed
But beware that the cookie still exists when users logout and login with a different username-password combination !!
So I have a counter for the number of likes, and depending on my activity I have a like or unlike link.
Ready! Some CSS whistles
After we have added some more (basic) CSS we are done! As a result we have created something much more modern that the old school comments display as we know from the IBM Domino Blog template.
If you are interested and want to receive the details of this setup I welcome you to send me a message and we can exchange code.
Add 20 years of experience to your workforce
You can 20 years of experience within IBM Notes and Web development to your workforce by hiring me.
Interested? Read my curriculum vitae on LinkedIn: http://www.linkedin.com/in/patrickkwinten and get in contact.
I am happy to work WITH you !