ColdFusion 10 loading java in script not implemented.. Yet!
Tags: Coldfusion, ColdFusion 10
Well the one thing that I really wanted to get my head around, and look at how this was implemented in ColdFusion 10, I found myself very disappointed with the current implementation.
I see that it works great if you want to use tags to call Java things, but as I now solely write in CFScript, I have to say either it is not implemented or it just doesn't work.
One of the things that I would have liked to see, was that ColdFusion adopt a more Java approach to using Java in ColdFusion. Something along the lines of what I have previously blogged about.
But so far it has not be done this way.
So when someone would like to write something like this, which I pulled directly from the release notes on how to use this from Adobe, then it will work fine.
<cfset y = myObj.init()>
<cfoutput>#y.testJava()#</cfoutput>
However if we would like to write this as script and use the new operator, then you are purely out of luck at the moment it seems. I have tried many different approaches, and have listed one below and feel that Adobe have again half implemented something that is really useless as it stands.
mx = new test();
writeOutput(mx.testJava());
</cfscript>
In the past I have blogged that it might look like the below example, and would have liked to have seen this in this release.
import myJava.test;
mx = new test();
writeOutput(mx.testJava());
</cfscript>
Now I realise that at the time of writing this, that ColdFusion 10 is only a preview release and that it may change over time. Lets just hope that it does, and that this is added quickly before release.
-
Couldn't you just use CreateObject?
var myObj = CreateObject("java","path.to.java.class").init();
http://www.cfquickdocs.com/cf9/#createobject.java -
Yes, and although I might not have made it clear. I was referring to using the new operand only, I still believe that using the import and new operand for Java should be introduced into ColdFusion.
# Posted By Andrew Scott | 2/22/12 6:42 AM



TweetBacks