2011-05-09 80 views
1

我想在JSF 2.0/ICEfaces portlet应用程序中使用内置注释功能(应用程序已经运行良好)。不幸的是,似乎还没有关于评论内容的详细文档,所以我希望有人可以给我一些指导,如何创建和检索应该链接到单个整数的评论。如何使用Liferay“评论框架”?

更加清楚...我希望(重新)在我的自定义portlet中使用“页面评论”Portlet的功能,但仅限底层服务,而不是UI部分。

我已经想通过EditDiscussionAction类,该Portlet使用MBMessageServiceUtil.addDiscussionMessage(...)。不幸的是,我不知道我应该提供什么参数值。任何人都可以对此有所了解吗?该javadoc是那种......总之;-)

public static MBMessage addDiscussionMessage(long groupId, 
              String className, 
              long classPK, 
              String permissionClassName, 
              long permissionClassPK, 
              long threadId, 
              long parentMessageId, 
              String subject, 
              String body, 
              ServiceContext serviceContext) 

干杯, tamm0r

回答

5

这将是很长,但这里是玩游戏。

  1. 在您看来,您将获取MBMessageDisplay对象。
MBMessageDisplay messageDisplay = 
     MBMessageLocalServiceUtil.getDiscussionMessageDisplay(
      themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), 
      MyModelEntry.class.getName(), myModelEntry.getTasksEntryId(), 
      WorkflowConstants.STATUS_APPROVED); 
  1. MBMessageDisplay将包含类似的threadId和parentMessageId重要数据,所以一定要发布这个数据也是如此。

  2. 在“控制器”,您在您的文章中提到的呼叫抓住从请求ServiceContext像这样:

    ServiceContext serviceContext = ServiceContextFactory.getInstance(
        MyModelEntry.class.getName(), actionRequest); 
    
  3. 所以你现在拥有所有所需的参数。

    long groupId - Group (Organization or Community usually) you're writing the comment in. 
    String className - MyModelEntry.class.getName() 
    long classPK - MyModelEntry's Primary Key or ID 
    String permissionClassName - Model where the permission checker should look, typically the same as className 
    long permissionClassPK - Its Primary Key or Id 
    long threadId - From MBMessageDisplay. 
    long parentMessageId - From MBMessageDisplay. 
    String subject - the subject 
    String body - the body 
    ServiceContext serviceContext - from Request in step 3. 
    

希望这有助于!