Skip to main content

Object Binding Example

In this example, you create a simple CSP page that does the following:

  • Uses <csp:object> to open the Contact object with id value 1.

  • Displays the values of the object's properties.

Here are the steps:

  1. Using the Studio CSP Wizard, create a new CSP page in the csp/user application. Name the page ObjectTest.csp.

  2. Modify the <body> tag and its contents so that it looks like the following. Note that the code uses CSP expressions to access the values of the object's properties.

    <body style="font-size:120%">
    <csp:object name="contact" classname="CSPTutorial.Contact" objid="1"/> 
    <p>Contact Name: #(contact.Name)#</p>
    <p>Contact Type: #(contact.ContactType)#</p>
    <p>Phone Numbers:</p>
    <script language="Cache" runat="Server">
    for i=1:1:contact.PhoneNumbers.Count()
      Set pn=contact.PhoneNumbers.GetAt(i)
      Write "<p>Type: "_pn.PhoneNumberType_" Number: "_pn.Number_"</p>"
  3. Click View —> Web Page to view the page.

generated description: object120142


In order to complete this example, you need to install and populate the Contact and PhoneNumber classes. For information on how to do this, read Part II Files in Installing Tutorial Files.

If you have a standard Caché installation, you do not need to configure this CSP application.

For a step-by-step guide to creating a CSP page using the Studio CSP Wizard, read the Sample CSP Page section of Part I of this tutorial.

To learn more about CSP Expressions, read CSP Elements: Expressions in Part I of this tutorial.

FeedbackOpens in a new tab