1

我试图阻止在 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 错误 [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

这是我的讨论.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);
4

2 回答 2

3

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

我认为 portlet 没有正确部署,请尝试重新部署 portlet,或者如果这无济于事,请尝试通常的做法:

  1. 取消部署 portlet
  2. 然后重新部署

如果这不起作用:

  1. 取消部署
  2. 停止服务器
  3. 清除临时目录
  4. 清除工作目录
  5. 启动服务器
  6. 部署 portlet
于 2013-04-01T14:29:22.890 回答
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 操作 URL

<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"));

     }

可能对某人有帮助。

于 2014-04-30T08:57:08.917 回答