Add rating functionality in message board portlet in liferay - liferay

I have to give rating functionality in message board portlet. for that I have created hook and override view.jsp file of message board portlet. I have added "liferay-ui:rating" tag as
liferay-ui:ratings
className="<%= MBMessage.class.getName() %>"
classPK="<%= message.getMessageId() %>"
type="stars"
I am getting error while deploying. what should be the values for className and classPK. Also from where can I get class name for message board and class primary key for the same.

Have it as shown below.
<liferay-ui:ratings
className="<%= MBMessage.class.getName() %>"
classPK="<%= message.getClassPK() %>"
type="stars"/>

Related

Liferay Embedded portlet does not call render function

I have looked everywhere for this bug and I have seen no other issue
Currently I am using Liferay 7.0 and I embedded my portlet in a web content template like so:
<div class ="container-fluid">
<div class ="row">
<div class ="col-md-6 col-sm-6">
<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />
<#liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
portletName="foo" />
${freeMarkerPortletPreferences.reset()}
</div>
</div>
</div>
Portlet works fine outside of the freemarker template, however inside it actionRequest button is called but it never enters render function so the buttons I set do nothing.
Is there any special requirement for a portlet to be put inside a freemarker template? Did I forget anything?
It seems that you are embedding by portletName so it can be either:
Instanceable, and then you need to provide its instance ID, as:
instanceId="INSTANCE_ID"
If not, set com.liferay.portlet.instanceable=false
If your portlet is instanceable, an instance ID must be provided; otherwise, you can remove this line. To set your portlet to non-instanceable, set the property com.liferay.portlet.instanceable in the component annotation of your portlet to false.

How can we create the back button in liferay

Can any one tell me how can I create the back button in my portlet. Are there any existing tags to create the back button which looks like as shared below.
Solution as mentioned in below post should work.
http://www.liferay.com/en_GB/community/forums/-/message_boards/message/22392288
Liferay uses back URL in many of its default portlets.
For example, You can refer sources for message board portlet - view.jsp, edit_category.jsp
If you use to move from first JSP to second JSP, then backURL should be passed as argument in first JSP and retrieve in second JSP to use inside liferay-ui:header tag.
For example,
<portlet:renderURL var="varURL">
<portlet:param name="mvcPath" value="<second-JSP-URL>"></portlet:param>
<portlet:param name="backURL" value="<%= themeDisplay.getURLCurrent() %>"></portlet:param>
</portlet:renderURL>
Try this instead.
Just use one line and it will direct back to previous URL.(Place this code in second jsp).
<input type=button value=" Back" onClick="javascript: window.history.go(-1)" text-align="right">

Error when rendering a Alloy UI form in Liferay

This is a form in my Liferay portlet.
<aui:form method="post" action="<%=loginURL%>">
<aui:fieldset>
<aui:input name="userName" label="Usernam">
<aui:validator name="required">
</aui:validator>
</aui:input>
<aui:input name="password" label="Password" type="password"></aui:input>
<aui:button type="submit" value="Login"></aui:button>
</aui:fieldset>
</aui:form>
When I deploy the portlet and go to the page that contains this form I get this error:
The aui:validator tag declares that it accepts dynamic attributes but does not implement the required interface.
I don't understand the problem. How can I fix it? Any help is appreciated in advance.
I don't understand the problem.
This answer will help you understand the problem in detail, though the answer is for spring tag still it applies to all custom tags created for JSP.
How can I fix it?
You can fix it by referencing the correct updated jar (util-taglib.jar) & including the correct TLD (aui.tld) inside WEB-INF/tld/ for your custom portlet.

Content rating control is always hidden

I've added the following code to the selected transformation of a News List webpart:
<%# Register Src="~/CMSAdminControls/ContentRating/RatingControl.ascx" TagName="RatingControl" TagPrefix="cms" %>
<cms:RatingControl ID="elemRating" runat="server" Enabled="true" RatingType="Stars" ExternalValue='
<%# Convert.ToString(CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatingValue"), 0)/((CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatings"), 0) == 0?1:CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatings"), 1)))) %>' />
The rest of the selected transformation is the same as the default.
According to the Kentico documentation this should add the webpart to the details page of a news item.
For some reason the input tag is getting rendered as follows:
<input type="hidden" name="p$lt$zoneContent$pageplaceholder$pageplaceholder$lt$News$NewsList$repItems$ctl00$ctl00$elemRating$RatingControl$elemRating_RatingExtender_ClientState" id="p_lt_zoneContent_pageplaceholder_pageplaceholder_lt_News_NewsList_repItems_ctl00_ctl00_elemRating_RatingControl_elemRating_RatingExtender_ClientState" value="0">
note the type="hidden" attribute. This causes the control not to render and I'm not sure where to fix this.
As mentioned in my comment. The is actually just used to store the value. Below that, it renders some extra content that will not display unless some CSS classes are carried over from the CMSDesk.css.
You can either copy the necessary CSS classes into your own CSS, or just import the CMSDesk.css file where necessary to make sure the rating elements are displaying.

How to get form field array in play framework

I'm using groovy to render templates in Play framework. I have a checkbox inside a list loop:
<input type="checkbox" name="chkUser[]" id="chkUser{users.getId()}" value="${users.getId()}">
How can i get the state of the checkbox array in Controller page.
Came across this a couple of monthes ago. It seems you can use find those back in controller using :
public static myFormFunction(boolean[] chkUser) {
...
Not sure of it and I cannot check this right now.
Take a look at the official documentation.
It can be achieved using hidden fields for every checkbox.
<input type="hidden" name="HdChkUser${users.getId()}">
<input type="checkbox" name="ChkUser${users.getId()}">
If the state of the checkbox changes then updating the hidden field value. Which can be used in for msubmission.

Resources