Skip to main content

The OnPage Method

The wizard also creates an OnPage method, which contains the code to display the page. To make our page do what we want it to do, we will add code to OnPage.

Here is the initial skeleton of the OnPage method provided by the wizard. It uses the &html<> directive to embed HTML in OnPage. The final line uses the Quit command to return the value, $$$OK, to indicate that the method completed successfully ($$$OK is a macro defined in the Caché library).

—TicketConfirm.OnPage—
TicketConfirm.OnPage

ClassMethod OnPage() As %Status
{
    &html<<html>
    <head>
    </head>
    <body>>
    ;To do...
    &html<</body>
    </html>>
    Quit $$$OK
}

The above code is functionally equivalent to the following more cumbersome code that uses the Write command to output the HTML. In fact, the compiler converts the above code into code much like the following when it compiles TicketConfirm.

—TicketConfirm.OnPage—
TicketConfirm.OnPage
ClassMethod OnPage() As %Status
{
    Write "<html>",!
    Write "<head>",!
    Write "</head>",!
    Write "<body>",!
    ;To do...
    Write "</body>",!
    Write "</html>",!
    Quit $$$OK
}
FeedbackOpens in a new tab