2. Linking elements

2.1. Defining exits

As mentioned, the elements have various exits that make it possible to connect the elements to each other. These exits are defined in the element declaration files. For an example, take a look at elements/guess.xml, where two exits, "start" and "success", are defined.

Example 3.2. Defining exits for an element

<element implementation="tutorial.numberguess.Guess"> 
  <exit name="start"/>
  <exit name="success"/> 

2.2. Creating the links

The relationships between the three elements, Start, Guess and Success, are defined in the site file, sites/numberguess.xml. It's there that elements are linked together and that the flow of the site is defined. All this is done by the appropriate flowlink tags:

Example 3.3. Defining flowlinks

  <element id="Guess" file="guess.xml" url="/guess">
    <flowlink srcexit="start" destid="Start"/>
    <flowlink srcexit="success" destid="Success"/>

This particular element, GUESS, has one link to the START element and one to the SUCCESS element. A flow link is always connected between an exit of an element and an element, and the exits of each element must be specified in the element's definition file.

The benefit of all this is that it's easy to get a clear overview of the relationships and flow between elements in a site just by looking at the site file. This is a great advantage when developing and maintaining web applications, especially big ones.