Topics

Implementing Auto-Watch


In This Guide

Auto-watch is a feature that automatically adds a user as a watcher after performing an action on that item. For example, if a user posts a comment to an article's conversation, that user 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 passed content.
  • 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.
In This Guide