beautypg.com

HP NonStop G-Series User Manual

Page 274

background image








Account # Balance
From:<%=ACCOUNT_ID[0]%> <%=SBALANCE[0]%>
To:<%=ACCOUNT_ID[1]%> <%=SBALANCE[1]%>

To substitute the placeholders in the template with the actual values of the data returned from the
service call, use the eval() method of the Template object shown in

Example 3-9

. This method

matches placeholders in the template file with fields of the same name in the results data and
replaces them accordingly. A check for valid results (output object) is done as shown in

Example 3-9

. If there is no output object, an error template page is returned.

Example 3-9. tlr.asp: Template Processing

path = Application("templatedir")
If (Not IsObject(output)) Or (output is Nothing) Then
Call template.evalFile(path & "\nosession.temp", Null)
Elseif output.noError() Then
Call template.eval(iodata)
Elseif output.applicationError() Then
Call template.evalFile(path & "\error.temp", iodata)
Else
'// System error
Dim errdata(0)
Set errdata(0) = Server.CreateObject("BEAWEB.TemplateData")
Call errdata(0).setValue("ERRNO", output.getError())
Call errdata(0).setValue("ERRMSG", output.getStringError())
Call template.evalFile(path & "\syserror.temp", errdata)
End If

Note

The array iodata contains both the input request and the results from the service call. This is
useful if you want the results page to contain data that is part of the input.

When the template is processed, the resulting HTML is returned to the client as shown in

Figure 3-3

.

Figure 3-3. tlr.asp Results Page