Skip to main content

Exercises

Exercise 1: Create a CSP page that outputs a series of radio buttons labelled: Strongly Agree, Agree, Neutral, Disagree, and Strongly Disagree. The CSP page should use the following elements:

  • A <csp:loop> tag that iterates five times. On each iteration it outputs a <input type="Radio"> tag.

  • A function named AddValue that returns “Strongly Agree”, “Agree”, “Neutral”, “Disagree”, or “Strongly Disagree” depending on the value of an integer passed to the method.

  • Two CSP runtime expressions. These expressions fill in the values (“Strongly Agree”, “Agree”, and so on) for the Value attribute and the content of each <input type="Radio"> tag. The expressions invoke AddValue passing it the current value of the <csp:loop> counter.

The page's output looks like the following:

generated description: part1exercise120142

Exercise 2: Create a CSP page that outputs the names of all of the contacts in the database. The contacts are divided into two groups on the page: Personal and Business. The CSP page should use the following elements:

  • A single <csp:query> tag. The tag uses the ByContactType query of the Contact class.

  • A <csp:while> tag that iterates through the query's result set and displays the contact names.

  • A <csp:loop> tag that executes the <csp:query> once for each type of contact.

  • A function that returns “Business” or “Personal” depending on the value of its integer argument.

  • CSP runtime expressions as needed.

The page's output looks like the following:

generated description: part1exercise220142

Note:

Completing Exercise 2 requires that you install and populate CSPTutorial.Contact in the USER namespace. PartIStarter.xml contains the class definition. For instructions on installing and populating, read Installing Tutorial Files.

PartIExerciseSoln.xml contains the solutions for both exercises. For instructions on locating this file and installing the solutions, read Installing Tutorial Files.

FeedbackOpens in a new tab