<cfx_HelloColdFusion name="Mr. X">
Take the example of “CFX_HelloColdFusion” from the specified source codes present. If you directly execute that CFX tag with the above code without doing anything to the server you will get the following error message.
"Error processing CFX custom tag CFX_HelloColdFusion.
The CFX custom tag CFX_HelloColdFusion was not found in the custom tag database. You must add custom tags to the database before using them. If you have added your tag to the database, check the spelling of the tag within your template to ensure that it matches the database entry."
So you need to follow the following steps in order to install that source code as a CFX tag.
- Compile the source code ("HelloColdFusion.java") file from the sample files of the ColdFusion installation by using the command prompt or by using any IDE and generate the "HelloColdFusion.class" file.
- For testing the CFX tag place the HelloColdFusion.class file in “cf_root/wwwroot/WEB-INF/lib” in Server configuration and place in “cf_webapp_root/WEB-INF/lib” for J2EE configuration. In this place when you make any changes to the java code you only need to replace the new .class file with the existing one. You don't need to restart the ColdFusion server on each changes to the .class built.
- You can also place your .class files in your specific directory by changing the Class path settings in ColdFusion administrator.(Server Settings->Java and JVM -> ColdFusion Class Path). After that you need to restart your ColdFusion server.
- Then you need to register your CFX tag in ColdFusion admin:
- Go to Extensions =>CFX Tags => Click Register Java CFX in ColdFusion admin. You will see a screen like below.
- CFX tag name starts with the prefix "cfx_" then the class name of the java code in our case the class name is "HelloColdFusion". So the vale for tag name input will be "cfx_HelloColdFusion".
- In Class Name field we need to provide the class name without any .class extension. e.g-"HelloColdFusion".
After all these steps if I will run the CFX code which I have written on the top of this page, I will get the following message as the output.
- In Description text area we need to add some description for that tag. e.g-This tag shows greeting message. This field is Optional we can skip it. But, it helps us when we have very large no of CFX tags.
"Hello, Mr. X"
For more details on CFX(java) in ColdFusion-9 have to wait for the next post. Thanks :)
1. CFX Custom Tag Part II