Since RIFE elements can contain only business logic and handle no user interaction at all, it's often appropriate to execute element chains with common behaviour and return to the point of origin. Typical examples of this are : logging out, selecting another language, selecting another theme, repositioning a row in a table, etc etc.
The behaviour chain for this is thus :
This snapback behaviour thus dynamically redirects the execution to the first element that the user visited. It allows you to independently provide the logic in dedicated elements and add them to your site structure with snapback flowlinks.
To define such a flowlink one merely has to remove the destid attribute and set the snapback="true" attribute instead.
For example :
<element id="CREDENTIALS" file="credentials.xml" url="/credentials">
<flowlink srcexit="logout" destid="LOGOUT"/>
</element>
<element id="LOGOUT" file="rife/logout/passthrough/memory.xml">
<flowlink srcexit="logged_out" snapback="true"/>
</element>
Where the credentials.xml element is declared like this :
<element implementation="tutorial.authentication.Credentials">
<submission name="logout"/>
<exit name="logout"/>
</element>
Thus a user visits the '/credentials' url, the content of the CREDENTIALS element is shown. It contains a link that sends the logout submission. The user clicks on that link, the CREDENTIALS element detects that it received the submission and activates the logout exit. This is linked to the LOGOUT element which logs the user out and activates its logged_out exit. This exit is linked through a flowlink that executes a snapback behaviour. Since the CREDENTIALS element was the first in the request, it will process that element and show its content for a logged-out user.