Skip to main content
Previous sectionNext section

Example Setup

In the following examples you experiment with the different properties of a Web Application definition. Begin by installing the example Zen application into the USER namespace. See the note below for the location of the example code. Read Importing Code Using Terminal for installation instructions.

The Zen application consists of three files:

  1. SecurityTutorial.Application — The Zen application definition.

  2. SecurityTutorial.HomePage — The main page of the application. It simply displays the values of the $UserName (user name) and $Roles (roles that the user belongs to) variables.

  3. SecurityTutorial.LogIn — The custom log in page for the application.

Here is the important code for SecurityTutorial.HomePage: the XDATA Contents block and the DrawMessage method:


/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
 <page xmlns="http://www.intersystems.com/zen" title="" >
 <html align="center">
 <h2>Home Page</h2>
 </html>
 <html align="center" OnDrawContent="DrawMessage">
 </html>
 </page>
}
Method DrawMessage(pSeed As %String) As %Status
{
 &html<<h1>USER: #($UserName)# </h1>>
 &html<<h1>ROLES: #($ROLES)# </h1>>
 Quit $$$OK
}
Copy code to clipboard

The code simply uses the DrawMessage method to display the values of $UserName and $Roles.

Here is the code for SecurityTutorial.LogIn:

/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="">
<html align="center"><h2>Login Page</h2></html>
<loginForm align="center" cellStyle="padding:5px;" id="form"> 
<text label="User:" name="CacheUserName" /> 
<password label="Pwd:" name="CachePassword" /> <submit caption="Login"/> 
</loginForm> 
</page>
}


Copy code to clipboard

This code creates a login page that allows the user to enter a user name and password. Note the following about the code:

  • It uses the Zen <loginForm> element to create the log in form.

  • The controls used for the user name and password each have a name attribute. The values are CacheUserName and CachePassword respectively.

Note:

The example Zen application is contained in Zen_Application.xml. The file is in install-dir\dev\tutorials\security. In a default Windows installation, install-dir is C:\InterSystems\Cache.

The examples in this section of the tutorial assume that you have installed Caché with Minimal security.

For more information on the %request object, read %CSP.Request Object in the HTTP Requests in CSP section of Using Caché Server Pages.