The numberguess example showed some of RIFE's power when it comes to using templates and submissions to handle forms and user input. In the next few chapters we are going to develop a somewhat more advanced application: a friends database application.
Our application will display a title and a list of friends and let us add new ones to the database. We also want to send a copy of the application to a friend when it's done, so that he can use it too. We don't want to make him change the code just in order to change the title though, so we will make sure that can be done easily through a configuration file instead.
The example is available in the same rife-examples package as the numberguess example from Chapter 3, Creating a more advanced RIFE application. To make it easier to follow, we provide you with the directory structure of the finished application:
Example 5.1. Directory structure of the friends application
src/ elements/ add.xml display.xml install.xml menu.xml remove.xml implementations/ tutorial/ friends/ Add.java Display.java Install.java Remove.java rep/ config.xml datasources.xml participants.xml sites/ friends.xml templates/ add.html display.html install.html menu.html remove.html tutorial/ friends/ backend/ Friend.java FriendManager.java
The application consists out of five different elements. Four of them have their own Java implementations and one uses an element that's already part of RIFE. All content is generated through templates and each element has a dedicated one. A friend is represented by the Friend
object and all friends are managed by a FriendManager
. We'll start off by setting up the site participant and defining the elements DISPLAY
, for listing the friends, and MENU
, for navigating the application.
Like in the previous example we use a ParticipantSite
participant to define the main site file.