Adobe COLDFUSION 9 Manual page 231

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
After you finish with development and testing, you can deploy your Java CFX tag anywhere on the classpath visible to
ColdFusion.
Customizing and configuring Java
Use the ColdFusion Administrator > Server Settings > JVM and Java Settings page to customize your Java
development environment by customizing the classpath and Java system properties, or by specifying an alternate JVM.
For more information, see the ColdFusion Administrator online Help.
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,
, which is passed
processRequest
The example in the following procedure creates a simple Java CFX tag named
text string back to the calling page.
Create a source file in your editor with the following code:
1
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 ) ;
}
}
Save the file as MyHelloColdFusion.java in the WEB_INF/classes directory.
2
Compile the java source file into a class file using the Java compiler. If you are using the command line tools
3
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 (
the fully qualified path; for example, c:\jdk1.3.1_01\bin\javac in Windows or /usr/java/bin/javac in UNIX.
If you receive errors during compilation, check the source code to make sure that you entered it correctly. If no errors
occur, you successfully wrote your first Java CFX tag.
Calling the CFX tag from a ColdFusion page
You call Java CFX tags from within ColdFusion pages by using the name of the CFX tag that is registered on the
ColdFusion Administrator CFX Tags page. This name should be the prefix
the .class extension).
Register a Java CFX tag in the ColdFusion Administrator
In the ColdFusion Administrator, select Extensions > CFX Tags.
1
Click Register Java CFX.
2
3
Enter the tag name (for example,
4
Enter the class name without the .class extension (for example,
(Optional) Enter a description.
5
6
Click Submit.
and
objects that are then used to do the work of the tag.
Request
Response
javac.exe
cfx_MyHelloColdFusion
Last updated 8/5/2010
cfx_MyHelloColdFusion
) is in your path. If it is not in your path, specify
_ followed by the class name (without
cfx
).
).
MyHelloColdFusion
226
that writes a

Advertisement

Table of Contents
loading

Table of Contents