Use $ to Instantiate Java Nested Static Classes in ColdFusion

Ok, so this isn't news; apparently its common knowledge to some that you can instantiate a nested Java class by using a $ instead of a . in the name:

<cfset local.RoundRectangle2D = CreateObject("java", "java.awt.geom.RoundRectangle2D$Float") />

I'm posting this because I found it impossible to locate this information on the web. I even had an Adobe tech tell me he was logging a bug that CF couldn't handle nested classes, because even he didn't seem to know that you could do this. Its now in the CF8 LiveDocs, and its now on my website. Perhaps the next person in line will be able to find it easier.

 

Transparent Rounded Corners for the Masses

Ok, so a late night of coding here… I should have been in bed like 2+ hours ago, but its all worth it because I've got it working: fully transparent rounded corners on your images. Just hit "more" to see the code.

 

Updates to Regex Tester

I've updated my old regular expression testing tool. Previously, it only did ColdFusion 8 regular expression testing. Now it also performs tests against Java's regular expression matching. Click here to view my ColdFusion 8 and Java Regex Tester.

 

Transparent Background

One of the big frustrations about CF8 image effects, is the lack of any way to get transparent writes or backgrounds. While most people think of transparent as just one more color, when you look at how Java handles pixels, you'll understand why Adobe didn't take the time to do this themselves.

 

Transparent Backgrounds for CF8 CFImage

Can you create an image with a transparent background, but it takes creating some Java objects. I'll be posting the code as part of an image effects set, but you an follow the steps here to figure out how to do it.

 

Implementing Sleep in CF

So I'm trying to import around 10,000 records through loops in CF7, because I have to tack in some additional info for each record... fun. I'd like to sleep the process for a bit, but CF7 doesn't have a built in method for that... Java objects to the rescue.

Java Object Sleep in CF7


<cfset objThread = CreateObject("java", "java.lang.Thread")>
<cfset objThisThread = objThread.currentThread()>
<cfset objThisThread.sleep(500)>

But, as someone at House of Fusion warns:

[The] thread [is] in the queue sleeping, and so if you have configged CF to use max 20 CF threads, and you sleep 20 threads, no requests will be handled by the server unless one of the threads gets free.

Below you can find the syntax for doing this in CF8, as mentioned by Jeff. Thanks for pointing that out Jeff!


<!--- Sleep current thread for 5 seconds --->
<cfset sleep(5000)/>

 

More Entries

Post a job. Find one. authenticjobs.com