Liferay UI <liferay:ui discussion/> working with Spring

We know, when we use liferay-ui with MVCPortlet, in MVCPortlet, it has a method called invokeDiscussionTagLib, but if we use Auto Annotation Scan in Spring, the controller class doesn't extend or implement any class, so we need to do our own implementation.

You can follow these steps:

1. In the JSP page,

<portlet:actionURL var="discussionURL">
        <portlet:param name="myaction" value="invokeTaglibDiscussion"></portlet:param>
</portlet:actionURL>

<liferay-ui:panel-container extended="<%= false %>" id="sloganCommentsPanelContainer" persistState="<%= true %>">
    <liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>" id="sloganCommentsPanel" persistState="<%= true %>" title="Comments">
            <liferay-ui:discussion classPK="<%=sloganPK%>" userId="<%=userId%>"
                className="<%=Slogan.class.getName()%>" subject="Comment"
                formAction="<%= discussionURL %>" formName="fm2"
                ratingsEnabled="<%= true %>" redirect="<%= currentURL %>">
                                                                    </liferay-ui:discussion>
    </liferay-ui:panel>
</liferay-ui:panel-container>

2. In the Spring MVC Controller class, you need to process the action. In your controller class, you can add the code below:

if("invokeDiscussionTagLib".equalsIgnoreCase(request.getParameter("myaction"))){
PortletConfig portletConfig = (PortletConfig) request
.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

Object[] args = new Object[] {
new NullWrapper("org.apache.struts.action.ActionMapping"),
new NullWrapper("org.apache.struts.action.ActionForm"),
portletConfig, request, response };


PortalClassInvoker
.invoke("com.liferay.portlet.messageboards.action.EditDiscussionAction",
"processAction", args);
}

This is the example working with Liferay 6.1.20





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值