Title: Event Listeners

Whenever an article (of any type) is posted to Traction, an event is generated. Listeners are plug-ins that can listen for these events and take any action.

Traction includes listeners for:



Additional listeners can be written using Traction's Java SDK. For more information on creating custom listeners, see the Knowledge Base article Server5519 (requires login).

To enable listeners, you must check the Enable checkbox.



The list of listeners currently configured appears below.



Starting with version 3.7, listeners can be individually enabled and disabled using the checkboxes in the last column.

How can I create a listener that updates a file with Traction view contents each time the server is updated?



The following reprint of the Knowledge Base article Support1032 is provided for developers.

The Url2File listener lets you specify a set of Traction views and the files to which their content should be written. Each time an entry is added to one of the matching projects, all the pages are updated.

One use for this is to have a static RSS XML file updated each time an entry is added to Traction, so that every RSS view doesn't have to demand extra CPU from the server.

Like all listeners, as many instances as you like can be registered; each listener can update one or more files.

To create a notifier called myrssnotifier that updates an RSS feed, first, create a new file "myrssnotifier.properties" in config/events/listeners/.

Note: Line breaks are significant! In this annotated example, lines beginning with # are comments and all lines shown using this style must start with a keyword followed by an = sign at the beginning of a line.

Into this file, add the line:

tractionview=tsi.sdk.view.listener.Url2File

This line specifies the Url2File listener, which handles updating the files.

Next, fill in the information that will appear in Server Setup | General, where the notifier can be turned on and off.

display_name=My RSS Feed Updater

description=Writes out a static copy of the RSS views we care about

Now, decided who the notifier will run as. Since we're doing a public RSS feed, we'll only include entries visible to Visitor.

# The user which this listener should run as. If unspecified, the listener runs as the

# user who posted the entry which triggered the listener

user=Visitor

Now, determine which projects should trigger the notifier to create output. Pay special attention to the requirement for a | pipe character before and after each project in the list.

# If set, updateprojects allows updates to happen only for the specified projects.

# there must be a | before the first and after the last project; the server

# checks for "|current project|" in the String below.

updateprojects=|Public|Comment|

# If set, skipprojects prevents updates for the listed projects. Same syntax rules # apply as for updateprojects.

skipprojects=|Private|

Finally, you can give a list of Traction URL's and the files to which they should be written. Note that filenames are relative to the server directory. Also note that each of the url/file pairs has a number after it, starting with 0.

# A list of urls and the files to which they should be published. all file paths are

# relative to the server directory, and all URL paths are relative to the root.

url0=/servlet/tsi.Submit?proj=Public&sdate=&edate=All&type=rchron&brief=y&skin=ajcrss&rsstitle=My%20Public%20Stuff

file0=pub/publicrss.xml

url1=/servlet/tsi.Submit?proj=Comment&sdate=&edate=All&type=rchron&brief=y&skin=rss&rsstitle=Your%20Comments

file1=pub/commentsrss.xml

Note there is one subtlety in the example above: the sdate= URL parameter has no value (is blank). This means "use now" for the start date.



Attachments:
image517.gif
image856.gif
Related Articles
Article: Doc98 (permalink)
Date: March 22, 2008; 3:58:13 PM EDT
Author Name: Documentation Importer
Author ID: importer