I'm trying to use the built-in comments functionality within a JSF 2.0/ICEfaces portlet application (the application is running fine already). Unfortunately there seems to be no detailed documentation about the comments stuff yet so I hope somebody can give me some pointers how to create and retrieve comments that should be linked to a single integer.
To be more clear... I'd like to (re-)use the "Page Comments" portlet's functionality within my custom portlet, but only the underlying service, not the UI part.
I already figured out that MBMessageServiceUtil.addDiscussionMessage(...) is used by that portlet through the EditDiscussionAction class. Unfortunately I have no clue what I should provide as parameter values. Could anybody shed some light on this? The开发者_Go百科 javadoc is kind of... short ;-)
public static MBMessage addDiscussionMessage(long groupId,
String className,
long classPK,
String permissionClassName,
long permissionClassPK,
long threadId,
long parentMessageId,
String subject,
String body,
ServiceContext serviceContext)
Cheers, tamm0r
This is going to be long but here is the play by play.
- In your view, you're going to grab the MBMessageDisplay object.
MBMessageDisplay messageDisplay =
MBMessageLocalServiceUtil.getDiscussionMessageDisplay(
themeDisplay.getUserId(), themeDisplay.getScopeGroupId(),
MyModelEntry.class.getName(), myModelEntry.getTasksEntryId(),
WorkflowConstants.STATUS_APPROVED);
MBMessageDisplay will contain vital data like the threadId and parentMessageId, so be sure to post this data as well.
In the "Controller" where you make the call mentioned in your post grab the ServiceContext from the request like so:
ServiceContext serviceContext = ServiceContextFactory.getInstance( MyModelEntry.class.getName(), actionRequest);
So you now have all the parameters required.
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.
Hope this helps!
精彩评论