Before you begin development of a CFX tag in C++, you can study the two CFX tags included with ColdFusion. These examples can help you get started working with the CFXAPI. The two example tags are as follows:
- CFX_DIRECTORYLIST: Queries a directory for the list of files it contains.
- CFX_NTUSERDB (Windows only): Lets you add and delete Windows NT users.
In Windows, these tags are located in the cf_root\cfx\examples directory. In UNIX, these tags are in the cf_root/coldfusion/cfx/examples directory.
Sun Workshop C++ compiler, version 5.0 or higher (gcc cannot be used to compile CFX code on Solaris)
Gnu C++ compiler - gcc
Before you can use your C++ compiler to build custom tags, enable the compiler to locate the CFX API header file, cfx.h. In Windows, add the CFX API include directory to your list of global include paths. In Windows, this directory is cf_root\cfx\include. In UNIX, this directory is cf_root/cfx/include. in UNIX, you need -I <includepath> on your compile line (see the Makefile for the directory list example in the cfx/examples directory).
CFX tags built in Windows and in UNIX must be thread-safe. Compile CFX tags for Solaris with the -mt switch on the Sun compiler.
In UNIX systems, your C++ library files can be in any directory as long as the directory is included in LD_LIBRARY_PATH or SHLIB_PATH (HP-UX only).
CFX tags built in C++ use the tag request object, represented by the C++ CCFXRequest class. This object represents a request made from an application page to a custom tag. A pointer to an instance of a request object is passed to the main procedure of a custom tag. The methods available from the request object let the custom tag accomplish its work. For information about the CFX API classes and members, see ColdFusion C++ CFX Reference in the CFML Reference.
After you configure a debugging session, you run your custom tag from within the debugger, set breakpoints, single-step, and so on.
You can debug custom tags within the Visual C++ environment.
- Build your C++ CFX tag using the debug option.
- Restart ColdFusion.
- Start Visual C++.
- Select Build > Start Debug > AttachProcess.
- Select jrunsvc.exe.Adobe recommends that you shut down all other Java programs.
- Execute any ColdFusion page that calls the CFX tag.
- Select File > Open to open a file in VisualDev in which to set a breakpoint.
- Set a breakpoint in the CFX project. The best place is to place it in ProcessRequest(). Next time you execute the page you will reach the breakpoint.
To use a CFX tag in your ColdFusion applications, first register it in the Extensions, CFX Tags page in the ColdFusion Administrator.
- In the ColdFusion Administrator, select Extensions > CFX Tags.
- Click Register C++ CFX.
- Enter the Tag name (for example, cfx_MyNewTag).
- If the Server Library .dll field is empty, enter the filepath.
- Accept the default Procedure entry.
- Clear the Keep library loaded box while developing the tag. For improved performance, when the tag is ready for production use, you can select this option to keep the DLL in memory.
- (Optional) Enter a description.
- Click Submit.
You can now call the tag from a ColdFusion page.