This example shows how to add an event to the system that will be fired whenever a user clicks on a particular link in a Web page. For instance, there might be several different links on your site that all lead to the same page, but you want to trigger different scenario actions depending on which of these links is clicked. Alternatively, you might simply want to record all clickthrough events to a dataset for later analysis.

To do this, we will create a JMS message called test.scenario.LinkMessage to represent a clickthrough. The message contains the logical name of the location that was clicked. Scenarios can then be created which intercept these clickthrough events and detect their locations. We will also create a Nucleus component named /test/scenario/LinkMessageSource that can be instructed to fire a LinkMessage by using a special <A> tag to set its location property. This permits any link in a page to selectively fire messages, as in this JHTML example:

<A HREF="PromotionDetail.jhtml"
   VALUE="Teaser">See details now!</A>

The example above provides a link to PromotionDetail.jhtml that, when clicked, fires a LinkMessage that carries the location Teaser.

Here is the same example in JSP code:

<dsp:a bean="/test/scenario/LinkMessageSource.location"
       value="Teaser" href="PromotionDetail.jsp">See details now!</dsp:a>

Note: This section was originally written for version 5.0 of the Scenarios module. A similar clickthrough event has since been added to the product as a standard scenario element. We have kept the example, however, because the basic procedure you follow is the same regardless of the event you are adding.

loading table of contents...