Implementing Auto-Watch
Auto-watch is a feature that automatically adds a user as a watcher after performing an action on that asset. For example, if an editor posts a comment to an article's conversation, that editor can automatically become a watcher on that article.
private static boolean processForm(ToolPageContext page, Recordable content) throws Exception {
post.save();
Record record = (Record) content;
record.sendMessage("watch.autoAdd", page.getUser());
/* Return true or false */
}
-
Commits the post associated with the
content
to the database. -
Instantiates a
record
variable based on the passedcontent
. -
Establishes a watch on the passed
content
for the user who posted the conversation.
The first parameter for the sendMessage
method is one of the following:
watch.autoAdd
—Adds the user unless the user previously removed the watch.watch.manualAdd
—Adds the user regardless if user previously removed the watch.watch.autoRemove
—Removes the user unless the user manually created a watch.watch.manualRemove
—Adds a user regardless if user previously created a watch.
Previous Topic
Configuring Watch
Next Topic
Applying type-specific overrides