Skip to main content

Posts

Showing posts with the label ColdFusion

ColdFusion to Sails.js Conversion : Find/Replace Tips/Tricks

Use your IDE of choice, I prefer Sublime Text because it uses the Perl Compatible Regular Expressions (PCRE) engine from the Boost library and I love me some regex. I will show examples for .js syntax, but if you need this in .ejs format just add <% to the beginning and %> to the end like in the first example below.  I always have the case sensitive button off in Sublime, so if you are using a different editor make sure you use the proper ignore case flag or you may get mixed results. These examples are meant to speed up the conversion, some additional refactoring may also be necessary. more to come...

ColdFusion to Node.js Conversion : Setup Part 1

This multi-part post will be community comment driven, which basically means that in an effort to not spend too much time on details that might not matter to the viewers out there, I am only going to share the details which I think are important at the time of publishing the posts. If people (or bots) comment and want more details, I will add them to the original post. As always, constructive criticism is always welcome. Since I am currently using the CFWheels framework (which is inspired by Ruby on Rails or RoR), I chose to try out the Sails.js framework for Node.js (which is also similar to Rails). 1st thing I did was get Node and Apache working together by adding this to my Apache vhost(VirtualHost) block: ProxyRequests on ProxyPass / http://localhost:8124/ And adding this to my hosts file (/etc/hosts): 127.0.0.1 mynewapp.node www.mynewapp.node This allows me to setup an alias in my host file and reference the URL as you normally would without adding the portnumber o...

CfWheels and Controller Init Caching Gotcha

I recently discovered an issue where logic inside of a controllers init gets cached when your environment is set to production. By default, when in the production environment the cfwheels setting of  cacheControllerInitialization defaults to true. At the time I had logic in the init method that checks if the user agent is CFSCHEDULER and the remote address is localhost/127.0.0.1. I used this logic to authenticate scheduled tasks that run on a secure section of the site. I found this when sporadically the authentication would pass even though the logic returned false and I noticed the init method was _never_ being called, which led me to find that caching setting. The fix was to extract the logic out into another method and add that to the list of filters. /************** Before **************/ <cffunction name="init"> <cfif CGI.remote_addr EQ "127.0.0.1" AND CGI.HTTP_USER_AGENT EQ "CFSCHEDULE"> <!--- let the CF ScheduledTas...

ColdFusion Invalid Image Format Solution

For those who have gotten the following error: "java.awt.color.CMMException: Invalid image format" and tried the solutions posted here with no avail. We are going to use the power of Java's JAI (Java Advanced Imaging) library to tackle this one. <cfscript> //path to image imagePath = "pathToImage"; //create java file object, passing in path to image imageFile = createObject("java","java.io.File").init(imagePath); //create a FileSeekableStream, passing in the image file we created fss = createObject("java","com.sun.media.jai.codec.FileSeekableStream").init(imageFile); //create ParameterBlock object and initialize it (call constructor) pb = createObject("java","java.awt.image.renderable.ParameterBlock").init(); //pass in FileSeekableStream pb.add(fss); //create JAI object that will ultimately do the magic we need JAI = createObject("java","javax.media.jai.JAI"); //...

CFBuilder 2 Tour comes to Nashville this week!

WHEN: Thursday, April 21st, 2011 at 6:00pm CDT WHERE: Russ Carroll Financial Peace Conference Center,1749 Mallory Lane, Brentwood, Tennessee 37027 Map of Location SPEAKER: Greg Wilson - Adobe evangelist for AIR, ColdFusion, Flex and LiveCycle ES WHAT: Greg Wilson from Adobe will be here to talk about CFBuilder 2, ColdFusion, and even some Flex on mobile stuff, including Flex on iPad/iPhone! We are SUPER excited to have the opportunity to get the surrounding ColdFusion and Flex communities together for this event. Greg Wilson is an AIR, ColdFusion, Flex, and LiveCycle ES evangelist at Adobe, and many of you may remember him from the ColdFusion 9 tour a couple of years ago. HOW: Register at the Nashville ColdFusion User Group site. RSVP for this meeting ...

Adobe ColdFusion tour coming to Nashville!

WHO: Greg Wilson (an AIR, ColdFusion, Flex, LiveCycle ES evangelist      at Adobe) WHAT: Greg will be discussing new features in ColdFusion, how      ColdFusion integrates with other Adobe technologies like AIR, Flex      and LCDS.      Also, Greg will be showing some demo's of the new features that      are going to be in the next ColdFusion release.      There will be food, drinks and of course prizes/giveaways that you      don't want to miss.(<cfhint = you have to be registered to be      eligible for giveaways!>) WHERE: Russ Carroll Financial Peace Conference Center,1749 Mallory      Lane, Brentwood, Tennessee 37027       Map of Location WHEN:Thursday, June 18, 2009 at 7:00pm CDT HOW: Register at the Nashville ColdFusion User Gro...

Try/Catch in OnError function of Application.cfc

So you're stoked that you switched to application.cfc and you wont have to see those hard ColdFusion errors since app cfc has the OnError function? Sorry to bust your bubble, but what if your OnError function throws an error(referencing a variable that isn't present for example)? Then what? That's right, a hard ColdFusion error will be shown and hopefully you were smart and turned off the Robust Exception option in the ColdFusion Administrator! :) To remedy this situation you could add in a try/catch block right there in the OnError function. A more generic process could be put in the catch block that perhaps should never throw an error, something very simple that doesn't reference any variables that may not be present.

Want to view a summary of your ColdFusion Components

If you need a quick overview of one of your ColdFusion components for documentation purposes for example, here is how you do it. Go to your browser of choice and type in the URL you use to get to your CF Administrator. For example, I access my CF Administrator with: http://127.0.0.1:8302/CFIDE/administrator/index.cfm Next delete everything after the CFIDE/ and copy and paste: componentutils/cfcexplorer.cfc?NAME=CFIDE.adminapi.datasource& METHOD=getcfcinhtml This will show you all the details about the datasource.cfc that is used in the coldfusion administrator. you can replace the 'CFIDE.adminapi.datasource' with any cfc you want to view. just replace that string with the component_name of your choice.

CFUNITED 09 Announced

CFUNITED 09 was just announced with dates, venue and early bird date. Info is as follows: Dates: August 11th, 2009 Pre-Conference Classes           August 12th-15th, 2009 Main event (repeat sessions on Saturday) Venue: Lansdowne Resort           44050 Woodridge Parkway           Lansdowne, VA 20176 Early Bird Date: December 31st, 2009 For more information visit CFUnited's travel page.

Using CFQueryParam in Order By Clause

With all of the SQL Injection attacks going on in the ColdFusion world I thought that it may be beneficial to show everyone a way that I know of to have cfqueryparam'd 'Order By' clauses. If anyone knows of other ways to accomplish this, please feel free to post a comment on how to do so. <cfquery name="GetData" datasource="#APPLICATION.DataSource#"> DECLARE @param varchar(25),    @dataID varchar(25),    @sql nvarchar(700); SELECT @param=<cfqueryparam cfsqltype="cf_sql_varchar" value="#VARIABLES.orderby#">,    @dataID=<cfqueryparam cfsqltype="cf_sql_varchar" value="#VARIABLES.DataID#">,    @sql = 'SELECT ID,       Phone_Number,       First_Name,       Last_Name,       Address    FROM Table WITH (NOLOCK)    WHERE DataID = ' + @dataID + 'Order by ' + @param + ...

Combining Select and Insert into the same CFQuery tag

So you want to grab some values and insert them into a table. Here is the hard way. <cfquery name="selectQuery" datasource="#application.dsn.db2#">     SELECT Setting1,Setting2,Setting3     FROM defaultSettings     WHERE ID = 101 </cfquery> <cfquery name="insertQuery" datasource="#application.dsn.db#"> INSERT INTO Settings     (TS,     Name,     Setting1,     Setting2,     Setting3) VALUES(GetDate(),     'Test',     <cfqueryparam cfsqltype="cf_sql_varchar" value="#selectQuery.Setting1#">,     <cfqueryparam cfsqltype="cf_sql_varchar" value="#selectQuery.Setting2#">,     <cfqueryparam cfsqltype="cf_sql_varchar" value="#selectQuery.Setting3#">) </cfquery> Here is the easier way, combining both Select and Insert i...

Using SQL's Scope_Identity

So you want to get the ID(PrimaryKey) of the last record inserted into the database without having to do a second cfquery block. Here is an example of doing it the hard way. <cfset value1 = 2007> <cfset myuuid = CreateUUID()> <cfquery name="insert" datasource="#APPLICATION.DSN.DB#">     INSERT INTO table(column1,column2)     VALUES(#VARIABLES.value1#, '#VARIABLES.myUUID#') </cfquery> <cfquery name="select" datasource="#APPLICATION.DSN.DB#">     SELECT ID     FROM table     WHERE column2=<cfqueryparam cfsqltype="cf_sql_varchar" value="#VARIABLES.myUUID#"/> </cfquery> You would then reference the ID as select.ID. The easier way. <cfquery name="insert" datasource="#APPLICATION.DSN.DB#">     INSERT INTO table(column1,column2)     VALUES(#VARIABLES.value1#, '#VARIABLES.myUUID#')     SELE...