View comments | RSS feed

Developing CFX tags in C++

The following sections provide information to help you develop CFX tags in C++.

Sample C++ CFX tags

Before you begin development of a CFX tag in C++, you might want to study the two CFX tags included with ColdFusion. These examples will help you get started working with the CFXAPI. The two example tags are as follows:

On Windows NT, these tags are located in the \cfusion\cfx\examples directory. On UNIX, these tags are in cf_root/coldfusion/cfx/examples.

Setting up your C++ development environment

The following compliers generate valid CFX code for UNIX platforms:
Platform
Compiler
Solaris
Sun C++ compiler 5.0 or higher (gcc does not work)
Linux
RedHat 6.2 gcc/egcs 1.1.2 compiler
HPUX 11
HP aCC C++ compiler

Before you can use your C++ compiler to build custom tags, you must enable the compiler to locate the CFX API header file, cfx.h. In Windows, you do this by adding the CFX API include directory to your list of global include paths. In Windows, this directory is \cfusion\cfx\include. On UNIX this directory is /opt/coldfusion/cfx/include. On UNIX, you will need -I <includepath> on your compile line (see the Makefile for the directory list example in the cfx/examples directory).

Compiling C++ CFX tags

CFX tags built in Windows and on UNIX must be thread-safe. Compile CFX tags for Solaris with the -mt switch on the Sun compiler.

Locating your C++ library files on Unix

On 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).

Implementing C++ CFX tags

CFX tags built in C++ use the tag request object, represented by the C++ class CCFXRequest. 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 CFML Reference.

Debugging C++ CFX tags

After you configure a debugging session, you can run your custom tag from within the debugger, set breakpoints, single-step, and so on.

Debugging on Windows

You can debug custom tags within the Visual C++ environment.

To debug C++ CFX tags in Windows:

  1. Build your C++ CFX tag using the debug option.
  2. Restart ColdFusion.
  3. Start Visual C++ 6.0.
  4. Select Build > Start Debug > AttachProcess.
  5. Select jrunsvc.exe.

    Macromedia recommends that you shut down all other Java programs.

  6. Execute any ColdFusion page that calls the CFX tag.
  7. Select File > Open to open a file in VisualDev in which to set a breakpoint.
  8. Set a breakpoint in the CFX project.

    The best place is to put it in ProcessRequest(). Next time you execute the page you will hit the breakpoint.

Registering CFX tags

To use a CFX tag in your ColdFusion applications, first register it in the Extensions, CFX Tags page in the ColdFusion Administrator.

To register a C++ CFX tag:

  1. On the ColdFusion Administrator Server tab, select Extensions > CFX Tags to open the CFX Tags page.
  2. Click Register C++ CFX.
  3. Enter the Tag name (for example, cfx_MyNewTag).
  4. If the Server Library .dll field is empty, enter the filepath.
  5. Accept the default Procedure entry.
  6. 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.

  7. (Optional) Enter a description.
  8. Click Submit.

You can now call the tag from a ColdFusion page.

To delete a CFX tag:

  1. On the ColdFusion Administrator Server tab, select Extensions > CFX Tags to open the CFX Tags page.
  2. For the tag you want to delete, click the Delete icon in the Controls column of the Registered CFX Tags list.

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


No screen name said on Apr 8, 2005 at 10:58 AM :
In order to debug a CFX tag, I had to attach to the process jrun.exe, not jrunsvc.exe. Also, from VStudio.net, go to Debug -> Processes and select the process from the list. Click attach, select the "Native" checkbox, ok and close.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/CFXTags7.htm