Exercises
The following exercises guide you through creating a CSP Contact Management System. The application consists of the following three CSP pages:
-
Contact.CSP — Displays all of the information, including phone numbers, for an individual contact. Users can edit contact, but not phone number information.
-
Phone.CSP — Displays all of the information for an individual phone number. Users can edit the information.
-
AddPhoneNumber.CSP — Use to create new phone numbers and add them to a contact.
Before completing these exercises, install and populate the Contact and PhoneNumber classes in the namespace in which you are working. See Install Tutorial Files for instructions.
Exercise 1: Contact.CSP: Create a CSP page named Contact.CSP. This page allows users to view and update contact information. Note that this page is partially created by an example in the body of Part II of the tutorial. Contact.CSP should satisfy the following requirements:
-
It includes a form that is bound to the Contact class. The form displays the Name, ContactType, and ID properties of a Contact instance. Users can update the Name and ContactType properties. Use the Studio Form Wizard to create this form. Note that the Form Wizard Example section of Part II of this tutorial contains the step-by-step instructions for this.
-
The form's “Search” page allows searching by ContactType. It displays both the Name and ContactType properties of the search results.
-
The page displays the Number and PhoneNumberType for each of the PhoneNumber instances belonging to the Contact instance open on the form. The phone numbers are retrieved from the database by either a dynamic or class query. The phone number display is not part of the form.
-
The page displays each phone number as a hyperlink that links to Phone.CSP (This page is created in Exercise 2).
-
Each hyperlink's URL contains a query string that includes the ID of its PhoneNumber instance as the value of OBJID.
Exercise 2: Phone.CSP: Create a CSP page named Phone.CSP. This page allows users to view and update phone number information. Phone.CSP should satisfy the following requirements:
-
It includes a form that is bound to the PhoneNumber class. The form displays the Numer, PhoneNumberType, ID, as well as the Name of the associated Contact. Users can edit the PhoneNumberType and Number properties. Use the Caché Web Form Wizard to create this form.
-
It includes a hyperlink that links back to Contact.csp. The hyperlink URL contains a query string that includes the correct Contact ID value for OBJID.
Exercise 3: AddPhoneNumber.CSP. Create a CSP page named AddPhoneNumber.CSP. This page allows users to add new phone numbers to contacts. AddPhoneNumber.CSP should satisfy the following requirements:
-
It provides a form for users to specify the PhoneNumberType and Number properties of the new PhoneNumber. The form also provides a “Save” button that activates the save routines. Note that this form should not be bound to any object. Do not use the Web Form Wizard to create it.
-
The new PhoneNumber instance is created and saved by either ObjectScript or Caché Basic function.
-
The “Save” button uses hyperevents to activate the function that creates the new PhoneNumber. The property values for the PhoneNumber are retrieved from the form using the HTML DOM.
-
The function that creates the new PhoneNumber assigns the correct Contact ID value to the PhoneNumber Contact property.
-
The page includes hyperlink that links back to Contact.CSP. The hyperlink URL contains a query string that includes the correct Contact ID as the value of OBJID.
PartIIExerciseSoln.xml contains the solution files for the exercises. For instructions on locating this file and installing the solutions, read Installing Tutorial Files.