« Torna a 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 Allegati
49812 Visualizzazioni
Media (3 Voti)
La media del punteggio è 3.3333333333333335 stelle su 5.
Commenti Autore Data
please tell me How and When doInterpreter()... Mahendra Mahakle 3 maggio 2011 8.12
Hi Friends, Very nice Wiki article. Just need... Nilesh Gundecha 4 maggio 2011 8.05
When portal render activities portlet, it will... Rujuan Xing 12 novembre 2012 6.33

please tell me How and When doInterpreter() method will call.
Inviato il 03/05/11 8.12.
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,
Inviato il 04/05/11 8.05.
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.
Inviato il 12/11/12 6.33.