2011-05-09 96 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. 
    

希望這有助於!