Caché Web Applications Tutorial
Determining the Number of TicketItems
[Home] [Back] [Next]
InterSystems: The power behind what matters   

Next, we are going to show some information about each order item.

We start by retrieving the TicketOrder object from the database using the Object ID stored in the %session object and assigning its oref to the variable ord. We use a line of Caché code to do this.
Whenever we want to use Caché code in a Web page, we simply enclose it within a standard <script> tag. The runat attribute indicates that the code runs on the server, not in the browser.
Now that we have a TicketOrder object, we can set up a loop to show each TicketItem. The number of iterations for the loop is determined by calling the method ord.Items.Count, which returns the number of TicketItem instances.
 <html> <head></head>
<csp:class super="%CSP.Page,Cinema.Utils">
<csp:if condition='$D(%session.Data("Order"))'>
    <img src="YourTicketOrder.gif"><br>
    <script language="cache" runat="server">
        // Open Order object for display
        Set ord = ##class(Cinema.TicketOrder).%OpenId(%session.Data("Order"))

    <csp:loop counter="num" from=1 to=#( ord.Items.Count() )#>
        . . .
</body> </html>

Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA