I’m sure this has been on Macromedia’s site for a bit, but it’s an interesting article for two reasons:
a) I’ve never really looked into the CFX documentation, but it appears from this article that creating a CFX, at least in Java, is a snap. Basically you implement the CustomTag interface, which means you only have to write one method, processRequest(), which looks very much like the doGet() method of the HttpServlet. After that you can write to the screen (ie: out.println() in servlet land == response.write() in CFX land), create a Query object for a CF page to loop over, or simply set a variable and return that variable to the calling template (response.setVariable() which is probably very much like request.setAttribute() in servlet land).
b) Couldn’t the author have done everything in a CF script using createObject() rather than using a CFX?
Yes – I think they could have used createObject() instead. The only issue is when you call methods that (may) return null. Since CF has no null, you have to handle it like so,
x = ob.method();
if(isDefined(“x”)) ….