XMLHTTP Operations and Fetch Pages

The ListSheet and TreeView HTML Components (HTCs) support a special class of operations in which a form is posted to a special type of page on the server. This type of page is known as a fetch page. Fetch pages are designed to process these operations and return the results as an XML document containing data in the standard XML data format.

Nothing besides the XML data can be present on the page being returned. Indeed, the content type of the page being returned must be set to "text/xml." Specifically, every fetch page should include the file BDXMLHeader.asp, which establishes the content type and other common page characteristics. Some of the lines from this include file are shown here with the two alternative forms of the first line, the second of which specifies the Norwegian IA5 codepage (do not duplicate line 1 in the actual include file):

 Line
   1    <%@ Language=VBScript %><%'@ Language=VBScript CodePage=1252 %><%
   1    <%'@ Language=VBScript %><%@ Language=VBScript CodePage=20108 %><%
   2
   3    ' switch the @ lines above to set a codepage
   4    ' that is different than the system locale
   5
   6    '   IE 5.5 supports the following settings for charset and codepage:
   7    '      (these are recommended though not all have been tested)
   8

At this point, the file BDXMLHeader.asp includes a list of possible CodePages. Refer to the actual file for details.

   n
 n+1    Option Explicit
 n+2
 n+3    if not isEmpty(Application("MSCSPageEncodingCharset")) then _
 n+4               Response.Charset = Application("MSCSPageEncodingCharset")
 n+5    Response.AddHeader "Pragma", "no-cache"
 n+6    Response.ContentType = "text/xml"
 n+7    Response.Expires = -1
 n+8    Response.Buffer = true
 n+9    %><?xml version='1.0' encoding='<%= Response.Charset %>' ?>
n+10

It is important that the content type of the returned page is set to "text/xml" so that the browser passes the data through to the existing list page, without re-rendering anything. The point of an XMLHTTP operation is to allow the ListSheet and TreeView HTCs to fetch and display new data from the server without reloading the entire list page.

Since the ListSheet HTC posts an XML document, the fetch page can access the various arguments included with the posted form by converting this XML request to a Dictionary object using the dGetRequestXMLAsDict routine. For example:

set g_dRequest = dGetRequestXMLAsDict()
sOperation = g_dRequest("op")

Another important consideration in the construction of fetch pages concerns include files. Since the data returned by the page must be pure XML, any client-side script or HTML will corrupt this XML and make it invalid. The file ActionPageUtil.asp is a good example of a file that must not be included in fetch pages for these very reasons.

At times, the fetch page may need to save some or all of the data passed to it as form arguments so that that data can serve as defaults for the remainder of the session. The ASP Session object is the most natural candidate for saving this type of data. A common example of this type of data is the criteria used within the find pane. If preserved in the Session object, these criteria can be available to be set as the default values in the event that the list page needs to be re-rendered (such as after returning from an edit page).


All rights reserved.