MessageManager Object Overview

The MessageManager object is usually created in the Global.asa file. Use the Active Server Pages (ASP) Server object’s CreateObject method to create a MessageManager object, as follows:

Set MSCSMessageManager = Server.CreateObject("Commerce.MessageManager")

Also in Global.asa, store the new object in the Application object, as follows:

Set Application("MSCSMessageManager") = MSCSMessageManager

The MessageManager object is used to associate sets of error messages with user languages or dialects. The MessageManager separates the text of these messages from the components that detect the errors, making it easy to support many languages while using the same code, site configuration, pipeline components and pipeline configuration.

For information about how the MessageManager is used in an application, see “Managing Languages and Error Messages” in Architecture of a Business-to-Consumer Site in the Commerce documentation.

The following example, from the Global.asa file for the Microsoft Press® sample site, illustrates the creation and initialization of a MessageManager object:

REM -- Create a message manager for use by the pipeline stages
Dim MSCSMessageManager
Set  MSCSMessageManager = Server.CreateObject("Commerce.MessageManager")
Call MSCSMessageManager.AddLanguage("usa", &H0409)
Call MSCSMessageManager.AddLanguage("FRA", &H040c)
Call MSCSMessageManager.AddLanguage("ENC", &H1009)
MSCSMessageManager.defaultLanguage = "usa"
Call MSCSMessageManager.AddMessage("pur_out_of_stock", "At least one item is out of stock.")
Call MSCSMessageManager.AddMessage("pur_badsku", "Products in your basket were deleted because they don't exist in this store.")
Call MSCSMessageManager.AddMessage("pur_badplacedprice", "Prices of products in your basket have been updated.")
Call MSCSMessageManager.AddMessage("pur_noitems", "An order must have at least one item.")
Call MSCSMessageManager.AddMessage("pur_badshipping", "Unable to complete order. Cannot compute shipping cost.")
Call MSCSMessageManager.AddMessage("pur_badtax", "Unable to complete order. Cannot compute tax.")
Call MSCSMessageManager.AddMessage("pur_badhandling", "Unable to complete order. Cannot compute handling cost.")
Call MSCSMessageManager.AddMessage("pur_badverify", "Changes to the data require your review. Please review and resubmit.")
Call MSCSMessageManager.AddMessage("pur_badpayment", "There was a problem authorizing your credit.  Please verify your payment information or use a different card.")
Call MSCSMessageManager.AddMessage("pur_badcc", "Bad Credit Card Number.")

In the preceding example, the MessageManager’s DefaultLanguage property is initialized to reference the message set called "usa", which has been added to the MessageManager through the call to AddLanguage. Because subsequent calls to AddMessage do not specify the message set with which each message is associated, the added messages are automatically associated with the default message set.


© 1997-1998 Microsoft Corporation. All rights reserved.