For administrators to change your app’s rating type (e.g. likes, stars, thumbs), you must implement rating type selection. The steps here show you how. For a detailed explanation of these steps and rating type selection, see Rating Type Selection.
-
Implement the
PortletRatingsDefinition
interface, registering the class as an OSGi component. In the@Component
annotation, set themodel.class.name
property to the fully qualified name of the class that will use this rating definition. This example rating definition is for a blog entry, so themodel.class.name
property is set tocom.liferay.portlet.blogs.model.BlogsEntry
:@Component( property = { "model.class.name=com.liferay.portlet.blogs.model.BlogsEntry" } ) public class BlogsPortletRatingsDefinition implements PortletRatingsDefinition {...
-
Implement the
PortletRatingsDefinition
methodsgetDefaultRatingsType
andgetPortletId
to return the entity’s default rating type and the portlet ID of the main portlet that uses the entity, respectively. In this example, the rating type is thumbs and the portlet ID is for the Blogs portlet:@Override public RatingsType getDefaultRatingsType() { return RatingsType.THUMBS; } @Override public String getPortletId() { return PortletKeys.BLOGS; }