liferay-ui:自定义portlet中的讨论标记

时间:2013-03-31 17:55:46

标签: liferay

我试图阻止jsp页面自定义portlet 允许对所显示的期刊文章发表评论

嵌入。 问题是它抛出g.ClassNotFoundException:org.apache.jsp.view_jsp如下

An error occurred at line: 119 in the jsp file: /discussion.jsp
The method setClassName(String) in the type DiscussionTag is not applicable for the arguments (Class<capture#2-of ? extends JournalArticle>)
116:            id="journalCommentsPanel" persistState="<%= true %>"
117:            title='<%= LanguageUtil.get(pageContext, "Comments") %>'>
118:
119:            <liferay-ui:discussion
120:            className="<%= journal.getClass() %>"
121:            classPK="31575"
122:            formAction="www.google.com"

15:57:13,540 ERROR [PortletRequestDispatcherImpl:108]

org.apache.jasper.JasperException: java.lang.ClassNotFoundException:
org.apache.jsp.discussion_jsp
org.apache.jasper.JasperException: java.lang.ClassNotFoundException:   
org.apache.jsp.discussion_jsp

这是我的discussion.jsp页面

<%
WindowState windowState = null;
PortletMode portletMode = null;

PortletURL currentURLObj = null;

if (renderRequest != null) {
    windowState = renderRequest.getWindowState();
    portletMode = renderRequest.getPortletMode();
    currentURLObj = PortletURLUtil.getCurrent(renderRequest,
            renderResponse);
} else if (resourceRequest != null) {
    windowState = resourceRequest.getWindowState();
    portletMode = resourceRequest.getPortletMode();
    currentURLObj = PortletURLUtil.getCurrent(resourceRequest,
            resourceResponse);
}

String currentURL = currentURLObj.toString();

ThemeDisplay themeDisplayObject = (ThemeDisplay) request
        .getAttribute(WebKeys.THEME_DISPLAY);
//long groupId = ParamUtil.getLong(request, "groupId", scopeGroupId);
long groupId = themeDisplayObject.getScopeGroupId();

String url = PortalUtil.getCurrentURL(request);
String[] urlString = url.split("/");
String urlTitle = urlString[urlString.length - 1];
urlTitle = HttpUtil.decodeURL(urlTitle).trim();

JournalArticle journal = JournalArticleLocalServiceUtil
        .getArticleByUrlTitle(groupId, urlTitle);
 %>

<portlet:actionURL var="discussionUrl">
    <!-- <portlet:param name="jspPage" value="/discussion.jsp" /> -->
</portlet:actionURL>


<portlet:actionURL var="editGreetingURL">
    <portlet:param name="jspPage" value="/view.jsp" />
</portlet:actionURL>


<liferay-ui:panel-container extended="<%= false %>"
    id="journalCommentsPanelContainer" persistState="<%= true %>">
    <liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>"
        id="journalCommentsPanel" persistState="<%= true %>"
        title='<%= LanguageUtil.get(pageContext, "Comments") %>'>
        <portlet:actionURL name="invokeTaglibDiscussion" var="discussionURL" />
        <liferay-ui:discussion 
        className="<%= JournalArticle.class.getName() %>"
        classPK="<%= journal.getArticleId() %>" 
        formAction="www.google.com"
        subject="Wall Comments"
        userId="<%= journal.getUserId() %>" />
    </liferay-ui:panel>
</liferay-ui:panel-container>


and this is my processAction method :


        PortletConfig portletConfig = getPortletConfig();
    //  System.out.println(">>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>> inside invoke");
         PortalClassInvoker .invoke(true, "com.liferay.portlet.messageboards.action.EditDiscussionAction",       
                          "processAction", new String[] {
                                          "org.apache.struts.action.ActionMapping",
                                          "org.apache.struts.action.ActionForm",
                                          PortletConfig.class.getName(),
                                          ActionRequest.class.getName(),
                                         ActionResponse.class.getName()
                          }, null, null, portletConfig, actionRequest, actionResponse);

2 个答案:

答案 0 :(得分:3)

您的错误在第120行className="<%= journal.getClass() %>"显示此代码,但您的discussion.jsp显示className="<%= JournalArticle.class.getName() %>",这是我认为的更正版本。

我认为portlet没有正确部署,尝试重新部署portlet,或者如果没有帮助尝试平常:

  1. 取消部署portlet
  2. 然后重新部署
  3. 如果不起作用:

    1. 取消部署
    2. 停止服务器
    3. 清除临时目录
    4. 清除工作目录
    5. 启动服务器
    6. 部署portlet

答案 1 :(得分:1)

我的工作正常

我的表,WallEntry。其中userid是用户的id。

List<WallEntry> wallEntry= WallEntryLocalServiceUtil.findByUserId(userId);
for (int i=0;i<wallEntry.size();i++)
{
 WallEntry wallobj=wallEntry.get(i);
 long id=wallobj.getWallEntryId();
}

portlet操作网址

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

liferay-ui:讨论标签

<liferay-ui:discussion 
    redirect="<%= themeDisplay.getURLCurrent() %>"  
    classPK="<%= wallEntry.getWallEntryId() %>" 
    userId="<%= user.getUserId() %>" 
    className="<%= WallEntry.class.getName() %>"   
    subject="" 
    formAction="<%= discussionURL %>" 
    formName='<%= "fm"+wallEntry.getWallEntryId() %>'  
  />

动作类

public void discussionURL(ActionRequest request,ActionResponse response) 
  throws Exception 
     {
     System.out.println("Inside addDiscussion function: "+request.getParameter("myaction"));

     }

可能对某人有帮助。