HTC Business Services Components Review
The previous example will prompt the user if he or she types in a new value that is invalid. If we used this example in a real application, we would need some way to submit the changes back to the server, where the new XML data is processed. As you can see, creating a fully working application using a browser interface is still a good deal of work.
We could have also used a method in our example to validate the fields. To do this, we could have added the following method to the HTC document:
<PARAMETER name="FieldName" />
<PARAMETER name="NewValue" />
The CheckValidity function written in VBScript would look as follows:
Function CheckValidity (FieldName, NewValue)
Select Case FieldName
If NewValue = "" Then
strError = "The PartNo is invalid."
If Not IsNumeric (NewValue) Then
strError = "The Quantity is invalid."
You would have to use the select case statement to test the FieldName and verify whether the NewValue is valid for that field. You can write the complete code for this function as an exercise.
In addition to writing business services components that use HTC, we could write business services components in Visual Basic, Java, or C++ and create compiled objects that are used by the HTML page. (It is also possible to create a compiled HTC, but this can only be done with C++, and the process is extremely complex.)
For example, you could create a business services component using a Visual Basic object that uses the DOM object to work with the XML data. We will not demonstrate how to do this here as the code we used to work with the DOM in Chapter 11 can be used to make either client or server components.
A compiled business services component might run more quickly than an HTC, but a compiled component might need to be installed on the client computer. In a controlled environment where you can be certain that a compiled component will easily install on every client, a compiled component may be the better choice. In an environment in which every client has Internet Explorer 5 installed, but there are many different types of clients, it might be better to use HTC.
In this chapter, we have created a business services component using an HTC running on the client that will validate the values of XML data located in a data island. This component will immediately tell users whether they have entered an invalid field and reset the text box to its previous value. We have also used the DSO to create an application that can allow the user to view the data contained within a data island. Using the DSO, we can create a Web-based user services component that can interact with the user using an HTC that encapsulates the business rules for the application.