« Back to Portlets

Adding Social Activity Tracking to a Portlet

Introduction #

The following tutorial will go through the steps needed to social activity tracking to a portlet. Recorded social activities will appear on the Activities portlet.

The examples will use the wiki as an example.

Add Activity #

The first step is to add social activity. You'll probably do this in a add() or update() method.

	userId, groupId, className, classPK, type, extraData, receiverUserId);
  • The type parameter, identifies the type of activity it is. You are free to define this however you want. See WikiActivityKeys for an example.
  • The extraData parameter is a string that can contain any additional info you want
  • receiverUserId is the user who the activity is done to.

In the wiki portlet, it looks something like the following

	userId, groupId, WikiPage.class.getName(), page.getResourcePrimKey(),
	WikiActivityKeys.ADD_PAGE, StringPool.BLANK, 0);

Remove Activity #

	className, classPK);

In the wiki portlet, it looks something like the following

	WikiPage.class.getName(), page.getResourcePrimKey());

Activity Interpreter #

Next, create an activity interpreter that extends BaseSocialActivityInterpreter.

Your activity interpreter class needs a getClassName() method that returns an array of class names. This should include the className used in the call to addActivity().

You'll also need a doInterpret(SocialActivity, ThemeDisplay) method that returns a SocialActivityFeedEntry. Your code should parse the SocialActivity argument to create the SocialActivityFeedEntry. In particular, you'll need a link, a title, and a body.

You code will looking something like

protected SocialActivityFeedEntry doInterpret(
		SocialActivity activity, ThemeDisplay themeDisplay)
	throws Exception {

	// parse activity

	String link = ...
	String title = ...
	String body = ...

	return new SocialActivityFeedEntry(link, title, body);

Add XML File #

Finally add the following liferay-portlet.xml for your portlet


where ActivityInterpreterClass is your activity interpreter class

0 Attachments
Average (3 Votes)
The average rating is 3.3333333333333335 stars out of 5.
Threaded Replies Author Date
please tell me How and When doInterpreter()... Mahendra Mahakle May 3, 2011 8:12 AM
Hi Friends, Very nice Wiki article. Just need... Nilesh Gundecha May 4, 2011 8:05 AM
When portal render activities portlet, it will... Rujuan Xing November 12, 2012 6:33 AM

please tell me How and When doInterpreter() method will call.
Posted on 5/3/11 8:12 AM.
Hi Friends,

Very nice Wiki article. Just need clarification on -
How The ActivitiesPortlet (like MembersActivitiesPortlet / UserActivitiesPortlet / FriendsActivitiesPortlet) will know about my defined custom activity type?? Should not I configure/define about my activity type to it??

Please provide me some inputs on this??

Thanks and Regards,
Posted on 5/4/11 8:05 AM.
When portal render activities portlet, it will render liferay-ui:social-activities tag which is used in view.jsp in ROOT/html/portlet/activities. The taglib render page is in ROOT/taglib/ui/social-activities/page.jsp. In the page.jsp, it'll call doInterpreter() method.
Posted on 11/12/12 6:33 AM.