Dovetail Survey Site Example
Kevin Gilpin
Last Updated...
Contents
The Survey Site example is meant to serve as a comprehensive example of the features and usage of Dovetail. It implements a web site which poses survey questions and records the responses. Users can optionally be required to log in to submit a response, the example site also implements user login and new user registration.
It consists of:
- build.xml : An Ant build file that you can use to build and run the Survey Site example
- xml/survey-site.xml : A Dovetail Site XML document which describes the site pages
- xml/survey-schema.xml : A Dovetail Database Schema XML document which describes the database tables and columns used by the site
- Java classes used to handle the form POSTs
- JSP pages which render the site HTML
This example includes an Ant build.xml file. Once you have obtained the necessary software described in the Installation Guide, you are ready to build the Survey Site. From the examples directory, run the following commands:
prompt% ant
prompt% ant java-tests
The first command will do everything necessary to build the Survey Site into the build directory. The second command will run a few example tests ( t-survey-1.xml and t-survey-2.xml, located in the xml directory ) on some sample data.
If you have problems with the build, make sure that your mysql database server is running. Please use the SourceForge-hosted Help forum if you have trouble getting things to work.
The Survey Site database schema is described in the survey-schema.xml document. It consists of three tables:
- RegisteredUser
- Stores information about the site users, including a login name (userID), and password
- Survey
- Stores survey questions. Each Survey also specifies whether the site user must log in before submitting a response
- SurveyResponse
- Stores a set of responses for each survey question
Some of the Dovetail features which are demonstrated in this document are:
- int, string, fixed-string, date, and boolean data types
- Specifying a column as a reference to another column. In this case a data type does not need to be specified; it is inferred from the reference
- Default values
- Column comments
- Primary keys
- Column indices
- NOT NULL constraints
- auto-incrementing columns (implemented as AUTO_INCREMENT for MySQL)
The Survey Site web site is described in the survey-site.xml document. It contains two directories, auth and surveys.
The auth directory contains two pages that are used to login and register site users:
- login
- Consists of a Form into which the user enters her userID and password. The login is verified by a server-side Java bean, VerifyLogin.
- register
- This page is used by new users to register with the site. They submit a userID, password, and some additional information about themselves to the Survey Site. This information is processed by the Register bean.
The surveys directory contains three pages that are used to collect and display survey results
- survey-ask
- Poses a survey question and lists the responses. The user's response is processed by the SurveyRespond bean, and the user is then sent to the survey-results page.
- survey-results
- This page displays a summary of the survey results
- survey-thanks
- This is a simple HTML page which thanks the user for submitting a survey response
Some of the Dovetail features which are demonstrated in this document are:
- Nesting of locations and pages
- Passing URL parameters (example : login.returnToURL parameter)
- Specification of links between pages, with URL parameters (example : survey-ask.login link)
- Form. Form elements, submit buttons, Java action-processing beans, redirection to a new page after processing (example : survey-ask.survey-respond form)
- SQL queries. Query results and query parameters. SQL query body (example : survey-results.show-responses query). Using query values (example : survey-ask.survey-repsond.responseID form element). Using URL parameters as query parameters (example : survey-results.show-survey.surveyID query parameter)
Home