View comments | RSS feed

Writing a Java CFX tag

To create a Java CFX tag, create a class that implements the Custom tag interface. This interface contains one method, processRequest, which is passed Request and Response objects that are then used to do the work of the tag.

The example in the following procedure creates a very simple Java CFX tag named cfx_MyHelloColdFusion that writes a text string back to the calling page.

To create a Java CFX tag:

  1. Create a new source file in your editor with the following code:
    import com.allaire.cfx.* ;
    
    public class MyHelloColdFusion implements CustomTag {
       public void processRequest( Request request, Response response )
    		throws Exception {
    		String strName = request.getAttribute( "NAME" ) ;
    		response.write( "Hello, " + strName ) ;
       }
    }
    
  2. Save the file as MyHelloColdFusion.java in the WEB_INF/classes directory.
  3. Compile the java source file into a class file using the Java compiler. If you are using the command-line tools bundled with the JDK, use the following command line, which you execute from within the classes directory:
    javac -classpath cf_root\WEB-INF\lib\cfx.jar MyHelloColdFusion.java
    

    Note: The previous command works only if the Java compiler (javac.exe) is in your path. If it is not in your path, specify the fully qualified path; for example, c:\jdk1.3.1_01\bin\javac on Windows or /usr/java/bin/javac on UNIX.

If you receive errors during compilation, check the source code to make sure you entered it correctly. If no errors occur, you successfully wrote your first Java CFX tag. For information on using your new tag in a ColdFusion page, see Calling the CFX tag from a ColdFusion page.

This section describes the following topics:


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

Version 7

Comments


ASandstrom said on Oct 19, 2005 at 7:17 AM :
The following blog entry has information about using a Java CFX in the J2EE configuration:
http://www.asfusion.com/blog/entry/cfxjar-not-in-class-path-coldfusion
ASandstrom said on Oct 19, 2005 at 11:00 AM :
The following blog entry has information about using a Java CFX in the J2EE configuration:
http://www.asfusion.com/blog/entry/cfxjar-- not-in-class-path-coldfusion. (Thank you to Marcel Scherzer for providing the link.)

 

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

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00001092.htm