alanwilliamson
The last few days I have been working on having the ability of declaring pure Javascript functions and making them available as first class, top-level, citizens in the CFML world.
Setting up a separate CFC can be done using the following:
<cfcomponent>
<cfjs>
function myMethod( param1, param2 ) {
return $cf.getTickCount();
};
</cfjs>
</cfcomponent>
Note that you can mix CFSCRIPT, Javascript and CFML in the one CFML/CFC file. Each one can declare a top-level function and you can use whatever language you feel works best for you for that particular method.
From there on in, you can simply declare the CFC as normal and use without any problems.
<cfset cfc = CreateObject("component","cfcinjs")>
<cfset x = cfc.myMethod( 1, 2 )>
We can now extend this principal and look to using the CFC in defining Application.cfc code. For example, we can now create a CFC that is subclassed by Application.cfc with all the necessary methods implemented using Javascript.
<cfcomponent>
<cfjs>
function onApplicationStart() {
$cf.print( "onApplicationStart.cfc" );
};
</cfjs>
</cfcomponent>
This is pretty darn sweet. Now you can define your CFC's in whatever language you want, and still expose it as pure CFML to those that wish to use it.
In addition to this change, I've made some significant performance gains, and in my tests, the overhead of running a CFC in Javascript and CFML is negligible.
The performance gains has been a huge boost, particularly when I load the JQuery library at the server-side and have it perform server-side DOM processing. That, I have to confess, even impressed me.
Still got some of the rough edges to polish off, but we are getting close to a proper beta release. Expect a code drop in the next day or two.
Article Details
We're Hiring
We are looking for passionate Java, CFML and Web developers who are wanting to solve some interesting problems and work with cutting edge technologies both in Scotland and the USA. Goto Jobs@AW2.0 for more details.
Related Articles
Article Archives
