Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Chapter 7. Enabling user collaboration > Adding discussions and ratings - Pg. 199

Adding discussions and ratings 199 and categories and make it available to your users. For now, though, we'll move on to some other ways you can get users to interact with your content. 7.5 Adding discussions and ratings Online interaction is what builds communities on the web. If your users can't interact with each other on your site, they probably won't find the site interesting after long. Liferay makes it easy to add discussions after you've implemented the asset framework for your entities. Liferay also makes it easy for users to rate your entities, either with a thumbs up / thumbs down, or by giving an entity from one to five stars. Ratings are pretty much as easy to implement as tags and categories: there's a tag for that. You need to make a slight architectural change in your portlet in order to support this functionality. Users who are commenting on or rating entities shouldn't be editing those entities, should they? This means you can't use the same JSP for editing and viewing, as you did for the Product Registration portlet. You'll create a view_slogan.jsp that displays a slogan and also allows users to comment on and/or rate it. You can see this JSP in the following listing. Listing 7.9 Discussions and ratings <%@include file="/html/init.jsp"%> <portlet:renderURL windowState="normal" var="backURL"> <portlet:param name="jspPage" value="/html/view.jsp" /> </portlet:renderURL> <liferay-ui:header backURL="<%= backURL %>" title="Slogan Contest Entry" /> <% Slogan slogan = (Slogan) request.getAttribute(WebKeys.SLOGAN_ENTRY); %> <h1><%= slogan.getSloganText() %></h1> <liferay-ui: ratings className="<%= Slogan.class.getName() %>" classPK="<%= slogan.getSloganId() %>" type="stars" /> b <liferay-ui:panel-container extended="<%= false %>" id="sloganCommentsPanelContainer" persistState="<%= true %>"> <liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>" id="sloganCommentsPanel" persistState="<%= true %>" title='<%= LanguageUtil.get(pageContext, "comments") %>'> <portlet:actionURL name="invokeTaglibDiscussion" var="discussionURL" /> <liferay-ui:discussion className="<%= Slogan.class.getName() %>" classPK="<%= slogan.getSloganId() %>" Ratings