Menu example application
ColdFusion MX is installed with a menu-based responder application. The menu application is written to work with any of the standard ColdFusion MX event gateways (SMS, XMPP, and Sametime) and with the Socket example event gateway, and ColdFusion MX is preconfigured with an instance of the application that uses SMS, as follows:
-
The Gateways page in the ColdFusion MX Administrator includes a gateway instance for this application that uses the SMS gateway type.
-
The gateway/cfc/examples/menu directory and its subdirectories include the CFML for the application
-
The gateway/config/sms-test.cfg file is configured to use this application with the SMS client (phone simulator), and short message service center (SMSC) server simulator that are provided with ColdFusion MX.
The application presents users with a drill-down menu of tools that they can use, including a weather report, stock information, status and configuration information, and language tools such as a dictionary.
The code for this application is relatively complex and is distributed among 13 files. The following brief description provides an overview of how it works. To get a full understanding of how the application works, see the source code.
-
The top level, menu, directory contains two files: Application.cfm and main.cfc.
-
The Application.cfm file consists of a single
cfapplication
tag that enables session management and names the application. Session variables maintain the current state information of the session, such as the active menu, and so on.
-
The main.cfc file contains the master CFC; the event gateway configuration in ColdFusion MX Administrator uses it as the listener CFC. The main CFC file processes CFEvent structures from the event gateway. It does the following:
- Inspects the gatewayType field to determine the rest of the structure contents. This is necessary because different event gateways put the message in fields with different names.
- If a Session.menu variable does not exist, initializes the menu system. To do so, it calls methods in two other CFCs: menu and menunode. These two CFCs contain the menu system code.
- Calls the session.menu.process method to process the user's input. This method can dispatch a message to an individual application for processing, if appropriate.
-
The apps directory contains several CFCs. Each file contains the code for a single application, such as the weather report or dictionary lookup (definition.cfc).
To use the menu application with the Socket event gateway:
-
On the Gateway Settings page in the ColdFusion MX Administrator, click the Start SMS Test Server button.
-
On the Gateways page in the ColdFusion MX Administrator, start the SMS Menu App - 5551212 event gateway by clicking the green play button (third button from the left in the Actions column). If the Status does not say Running after a few seconds, click Refresh to check that the server started.
-
In the cf_root\WEB-INF\cfusion\bin directory on J2EE configurations or the cf_root\bin directory on server configurations, run the SMSClient.bat file (on Windows) or SMSClient.sh file (on UNIX or Linux) to start the SMS phone simulator. The simulator is preconfigured by default to "call" the default SMS event gateway configuration.
-
Enter any character by typing or by using the mouse to click the simulator keypad, and press Enter on your keyboard or click Send on the simulator.
-
The menu application responds with the top-level menu. Enter L for language tools such as a dictionary and thesaurus, S to get stock quotes or weather forecasts, or C to get information about the server. Press Enter on your keyboard or click Send on the simulator.
-
The application displays a submenu. For example, if you select S in step 5, the options are Q for a stock quote, W for weather, or B to go back to the previous menu. Enter your selection.
-
The application requests information such as a Zip code for the weather, stock symbol for a price, word for the dictionary, and so on. Enter and send the required information (or enter B to go back to the menu).
-
The application gets and displays the requested information. Depending on the application, you might also be prompted to enter M to get more. Enter M (if there is more information available), another term, or B to return to the previous menu.
-
Continue by entering menu items and detailed information requests.
-
To exit, select File > Exit from the menu bar.
View comments in LiveDocs