ColdFusion Splendor – When to use invokeCFClientFunction

April 20, 2014 / Ram Kulkarni

  Adobe ColdFusion | ColdFusion 11 | Mobile | Splendor

This post is reproduced from my post at my personal blog

I have seen some confusion when it comes to using invokeCFClientFunction. I have been asked this question a few times, more recently on LinkedIn, so I thought explaining it in a blog post might be a good idea.

If you don't know already, ColdFusion Splendor has added support for client side CFML (<cfclient>) and this code is translated to JavaScript.  You can call JavaScript functions from cfclient and vice versa.

cfclient also makes calling asynchronous functions of PhoneGap easy by providing synchronous access to them. All device APIs are asynchronous in nature, but in cfclient block you call then as synchronous functions and ColdFusion translates them to asynchronous PhoneGap functions. All function starting with 'cfclient.', e.g., are asynchronous. In addition to device APIs, data access function, executeQuery and tag, cfquery, are also asynchronous in cfclient.

When you call asynchronous functions in cfclient, ColdFusion takes care of chaining callback functions - any code following an asynchronous function goes in the success callback function. But if you call asynchronous cfclient function form JavaScript code block, then ColdFusion compiler does not touch it. Note that if a UDF in cfclient block calls any asynchronous function (e.g. cfquery or any device APIs) then that function also becomes asynchronous.

Let's see an example. In the following code, I have a UDF in cfclient block, createDatabase. It does not need any argument, but let's say it takes one argument, arg1. This function calls queryExecute function, which is an asynchronous function - so createDatabase function also becomes asynchronous. If you call it from JavaScript and have some JS code to be executed only after database is created, then calling createDatabase function directly from JavaScript is not going to work as expected -

Read More

Language Enhancements in ColdFusion Splendor - Promoting built-in CF function to first class

April 15, 2014 / Awdhesh Kumar

A while ago I started a series of blog posts on Language Enhancements in ColdFusion Splendor and today, taking it forward, I am going to write about built-in ColdFusion functions being promoted to first class objects.

A first class object is the one which could be passed as an argument to a function call, assigned to a variable or returned as a result of a function invocation. So by promoting built-in functions to first class objects, you will be able to treat ColdFusion functions (structInsert, arrayLen, listFind) as objects and hence you can:

Here is a very simple example showing how you can pass built-in functions as an argument:

	function convertCaseForArray(Array array, function convertor)
		for (var i=1; i <= arrayLen(array); i++){
        	array[i] = convertor(array[i]);
		return array;
     // lcase built-in function is being passed as callback.
	resultantArray = convertCaseForArray(['One', 'Two','Three'],  lcase);	

In the above example, lcase built-in function is directly being passed as an argument to convertCaseForArray, which was not allowed till ColdFusion10. Now, let's see an example where the lcase and ucase built-in functions are being returned from the getConvertFunc function based on the type:

	function convertCaseArray(Array array, String caseTo)
		caseConvertFunc = getConvertFunc(caseTo);
		for (var i=1; i <= arrayLen(array); i++){
        	array[i] = caseConvertFunc(array[i]);
		return array;
	function getConvertFunc(String caseType)
	  if(caseType == 'lower')
	  	return lcase;
                return ucase;
	resultantArray_lower = convertCaseArray(['One', 'Two','Three'], "lower");
	resultantArray_upper = convertCaseArray(['One', 'Two','Three'], "upper");


In the above example, getConvertFunc returns the convertor for the right case. 

Stay tuned for more posts on language enhancements!

Slides of e-seminar - Everything about Mobile Application Development

April 11, 2014 / Ram Kulkarni

  Thunder | Adobe ColdFusion | Adobe ColdFusion Builder | e-seminar | Mobile | Splendor

I presented an e-seminar, Everything about Mobile Application Development, on 10th April. Some of the attendees had asked me to share the presentation and source code of the application. So here are the links

I had added a few useful links at the end of the presentation, but the PDF (linked above) of slides does not show those links. So here they are - 


ColdFusion Documentation

CFMobile related Blogs

CFMobile related Videos

Recently PhoneGap Build made some changes in the way they pick up PhoneGap plugins. Because of this if you package the application (CFMobileExpenseTracker) using Public Beta builds, then image attachement feature would not work. We have fixed this issue post public beta. However there is a work around in public beta build- In the PhoneGap project properties of ColdFusion Thunder, select 'Load the configuration from XML' option and use this config.xml.

You can find the recording of this e-seminar here.

-Ram Kulkarni

Adobe ColdFusion Summit 2014

April 11, 2014 / Elishia

  Adobe ColdFusion | Adobe ColdFusion 10 | Announcements | CF Summit | ColdFusion | ColdFusion 11 | General

We are pleased to officially announce the next Adobe ColdFusion Summit to be held October 16th and 17th at Aria Resort & Casino, Las Vegas, Nevada.  It's going to be even better than last year and pricing remains very low at $299 early bird rate through July!

Read More

Language Enhancements in ColdFusion Splendor - Elvis operator

April 08, 2014 / Awdhesh Kumar

The Elvis operator (?:) is a small but elegant feature added in Splendor. I am going to show you how it shortens your conditional code and  makes it look simpler. But before I get into the details, here is the list of language features added in ColdFusion Splendor.

The Elvis operator assigns the ‘right default’ for a variable or an expression. In an expression, if the resultant value is not defined, then the object will be assigned to the left most part of the expression otherwise a default value (define at the right most part) will be assigned.

Consider a conditional case where the displayname is populated with username variable, if the later is defined otherwise a default value "anonymous" needs to be assigned to the displayname variable. The code snippet shown below display both the syntaxes: one with Elvis operator and other without it:
Without Elvis
       displayName = username;
   else {
    displayName = "anonymous";

With Elvis operator

   displayName = username ?: "anonymous";

The support for Elvis operator has been provided for function calls and expressions too. Some of the expression cases are: 

 securityNumber = securityStruct[‘Joe’] ?: -1;  // Retrieving from a struct
 colourCode = colourArray[index] ?: "black";   // Retrieving from an array
 employeeName = getEmployeeName(ID) ?: “Joe”;  // A function call

Blue Mango Theme Design By Mark Aplet

Super Powered by Mango Blog