SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Language Enhancements in ColdFusion 11 (Splendor)
Ram Kulkarni
1
@ram_kulkarni
ramkulkarni.com
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Language Enhancements in ColdFusion 11
§  Full CFScript support
§  Member functions for data types
§  JSON enhancements
§  Query functions
§  Elvis operator
§  Built-in functions as data type
§  Collection functions
§  Application specific dynamic datasource
2
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Tags in CFScript
3
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Tags in CFScript
§  Can call most tags in cfscript
§  Call tags as functions
§  Name of the function is same as tag name
§  Attributes are passed as name-value pair separated by comma
§  Example
<cfscript>
cfdocument (format="PDF" ,src="report.cfm");
</cfscript>
4
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Tags in CFScript– child tags
<cfscript>	
  
	cfchart ( format="html")	
  
	{	
  
	 	cfchartseries (type="bar", seriescolor="##4dc", label="Sales")	
  
	 	{	
  
	 	 	cfchartdata (item="Jan" ,value="100" );	
  
	 	 	cfchartdata (item="Feb" ,value="400" );	
  
	 	 	cfchartdata (item="Mar" ,value="200" );	
  
	 	 	cfchartdata (item="Aprl" ,value="500" );	
  
	 	 	cfchartdata (item="May" ,value="700" );	
  
	 	 	cfchartdata (item="Jun" ,value="300" );	
  
	 	}	
  
	}	
  
</cfscript>	
  
5
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Tags in CFScript– using writeoutput
<cfscript>	
	name = "Ram";	
	cfsavecontent (variable="var1" )	
	{	
	 writeOutput("<b>");	
	 writeOutput("Hello #name# !<b>");	
	}	
		
	writeOutput(var1);	
</cfscript>
6
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Custom Tags in CFScript
Call custom tags in cfscript with “cf_” prefix
<cfscript>	
	cf_sayHello(name="Ram");	
</cfscript>	
	
Using imported custom tags
<cfimport prefix="hello" taglib="customtags">	
	
<cfscript>	
	hello:sayHello(name="Ram");	
</cfscript>	
7
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Tags not available in CFScript
§  cfscript
§  cfoutput
§  cfdump
§  cfinvoke
§  cfinvokeargument
§  cfobject
§  cfset
8
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Data Type Member Functions
9
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Member Functions for Data Types
§  Access functions on data types as member functions
Example
<cfscript>	
	st = {	
	 	firstName: "Ram",	
	 	lastName: "Kulkarni"	
	};	
		
	writeDump(st.find("firstName"));	
	//structFind(st,"firstName");	
		
	st.append({company:"Adobe"});	
	//structAppend(st,{company:"Adobe"});	
		
	writeDump(st);	
</cfscript>
10
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Supported Data Types
§  Array
§  Struct
§  List
§  Date
§  String
§  Query
§  Xml
§  Image
§  Spreadsheet
11
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
JSON Enhancements
12
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
JSON Enhancements
§  Case of Struct keys now are preserved
§  Select option “Preserve case for Struct keys for Serialization”
in the Administrator->Settings
§  Data types inferred for Query columns and CFC properties
§  Option to serialize Query as Struct
§  Custom Serializers
13
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
JSON Case Sensitivity
§  Setting case preservation for Struct keys
§  Application Level
§  Server Level
§  Application.cfc setting
component {	
	this.name = "JSONEnhancements";	
	this.serialization.preserveCaseForStructKey = true;	
}	
	
§  Server setting in ColdFusion Administrator	
14
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Type of data preserved in CFC and Query
§  ColdFusion is loosely typed language
§  It infers data type based on value assigned
§  But sometime it can get data type wrong
e.g. “0123” could be converted to number 123
§  JSON Serialization for Query
§  Infers data type from column type of Database
§  JSON Serialization for CFC
§  Infers data type from ‘type’ attribute of CFC property
15
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Serialize Query as Struct
§  Before ColdFusion 11
§  serializeJSON (object [,boolean queryFormat])
§  In ColdFusion 11
§  serializeJSON (object [, object queryFormat])
§  Second argument could be
§  True, False, “row”, “column”, “struct”
§  Application.cfc setting
component {	
this.serialization.serializeQueryAs = "struct";	
}
16
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Custom Serializer
§  New serialize functions
§  serialzeXML and deserializeXML	
§  serializeJSON and deserializeJSON already existed	
§  Set custom serializer in Application.cfc
component {	
	this.customSerializer = "MyJSONSerializer";	
}	
	
§  Create a CFC for custom serialization and implement following functions –
function canSerialize (type) access="remote" returntype="boolean”
function serialize (objToSerialize, acceptHeader) access="remote" returntype="String”	
function canDeSerialize (type) access="remote" returntype="boolean" 	
function deSerialize (objToSerialize, acceptHeader) access="remote" returntype="String" 	
	
17
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Query Functions
18
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
queryExecute
§  Syntax
queryExecute (sql [,queryParams] [,queryOptions])
§  Examples:
<cfscript>	
	rs = queryExecute("select * from employee",[], {datasource:”EmployeeDS”});

	
	rs = queryExecute("select * from employee where id = ?", [1]);

	
	rs = queryExecute("select * from employee where id = :empId", {empId:1});

	
	rs = queryExecute("select * from employee where id = :empId", {empId:
{type="integer", value=1}});

	
	rs = queryExecute("select * from employee where id = :empId and first_name
like :firstName", {empId:1, firstName:"Ram"});	
</cfscript>
19
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
queryGetRow Function
§  Retrieves specific query row
§  Result is returned as Struct
§  Throws RowNumberOutOfBoundException if index is greater than num rows
§  Syntax:
row = queryGetRow (queryObj, rowIndex) OR
row = queryObj.getRow(rowIndex)
<cfscript>	
	queryObj = queryExecute("select * from employee order by first_name");	
		
	writeDump(queryObj); 		
	writeDump(queryObj.getRow(2));	
	writeDump(queryGetRow(queryObj, 1));	
</cfscript>
20
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Other Language Enhancements
21
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Elvis Operator
§  Special case of Ternary operator - ?:
<cfscript>	
	var1 = isDefined("var2") ? var2 : "defaultValue";	
	writeOutput(var1 & "<br>");	
		
	var1 = var2 ?: "defaultValue";	
	writeOutput(var1);	
</cfscript>	
	
Output is the same – “defaultValue”
22
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Build-in functions as data types
§  Pass built-in function as function argument
§  Return built-in function from a function
§  Assign built-in function to a variable
You could do all of above with UDFs earlier, now supported for built-in functions
<cfscript>	
	a = [10, 44, 55, 60];	
	
	function arrayOperation (opFunc)	
	{	
	 	return opFunc(a);	
	}	
		
	writeOutput("Array Max = " & arrayOperation(arrayMax) & "<br>");	
	writeOutput("Array Min = " & arrayOperation(arrayMin) & "<br>");	
	writeOutput("Array Average = " & arrayOperation(arrayAvg) & "<br>");	
§  </cfscript>
23
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Enhancements to collection functions
§  Index and array object arguments added to closure function of arrayEach
§  arrayEach(array, function (arrayElement, index, arrayObj) { … });
§  New function listEach
§  listEach
(
list/String,
function (listObj, index){}
[, delimiters_string]
[, includeEmpltyFields_boolean]
)
24
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Enhancements to collection functions - Continued
§  arrayReduce
§  arrayReduce (arrayObj, function(prevResult,item, index, arrayObj){});
§  Returns a single value
§  arrayMap
§  arrayMap (arrayObj, function (item, index, arrayObj){});
§  Replaces value of array element at given index and returns new array
§  Similarly structReduce, structMap, listReduce and listMap are added
25
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Application Specific Datasource
§  Ways to create datasource
§  In the Administrator
§  Using Admin API
§  CF11 – New way to create dynamic datasources
§  In application.cfc
this.datasources.myDataSource = {	
database = “path_to_folder",	
driver = "Apache Derby Embedded"	
};	
this.datasource = "myDataSource";
26
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Application specific datasource – continued …
§  Creating datasource using JDBC URL
this.datasources.dsn2={"driver"="MSSQLServer",
url="jdbc:macromedia:sqlserver://localhost
MSSQL2008;databaseName=regression;;sendStringParametersAsUnicode=false;querytimeout=0;M
axPooledStatements=1000","username"="sa","password"="pass"};
§  In case of clash, Application datasource will get preference
27
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
CFZip Enhancements
§  Support for password protected zip files
§  CFZip – added two attributes
§  password
§  encryptionAlgorithm – Standard, AES-128, AES-256 (default)
<cfscript>	
cfzip (action="zip", file="C:ZipTesttestzipfile.zip", 	
	source="C:ZipTestsample.txt", password="pass");	
	
cfzip (action="list", name="zipFileList", 	
	file="C:ZipTesttestzipfile.zip");	
	
cfzip (action="unzip", 	
	file="C:ZipTesttestzipfile.zip", 	
	destination="C:ZipTest", password="pass", overwrite="true");	
</cfscript>	
28
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
CFZip Enhancements
§  Can specify password for individual files
<cfscript>	
cfzip(action="zip", 	
	file="C:ZipTesttestzipfile.zip", overwrite="true")	
{	
	cfzipparam(source="C:ZipTestsample.txt", password="pass");	
};	
	
cfzip(action="unzip", file="C:ZipTesttestzipfile.zip", 	
	destination="C:ZipTest", overwrite="true")	
{	
	cfzipparam(source="sample.txt", password="pass");	
};	
</cfscript>
29
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Thank you
30
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.

Weitere ähnliche Inhalte

Was ist angesagt?

A JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 BerlinA JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 Berlin
Alexander Klimetschek
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublic
Kaing Menglieng
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
PrinceGuru MS
 

Was ist angesagt? (20)

Configuration beyond Java EE 8
Configuration beyond Java EE 8Configuration beyond Java EE 8
Configuration beyond Java EE 8
 
PHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi MensahPHP Oracle Web Applications by Kuassi Mensah
PHP Oracle Web Applications by Kuassi Mensah
 
Rails and Legacy Databases - RailsConf 2009
Rails and Legacy Databases - RailsConf 2009Rails and Legacy Databases - RailsConf 2009
Rails and Legacy Databases - RailsConf 2009
 
Spring Data for KSDG 2012/09
Spring Data for KSDG 2012/09Spring Data for KSDG 2012/09
Spring Data for KSDG 2012/09
 
Let ColdFusion ORM do the work for you!
Let ColdFusion ORM do the work for you!Let ColdFusion ORM do the work for you!
Let ColdFusion ORM do the work for you!
 
Power shell voor developers
Power shell voor developersPower shell voor developers
Power shell voor developers
 
Php Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPhp Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi Mensah
 
PHP Oracle
PHP OraclePHP Oracle
PHP Oracle
 
A JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 BerlinA JCR View of the World - adaptTo() 2012 Berlin
A JCR View of the World - adaptTo() 2012 Berlin
 
Power of Simplicity in FW/1
Power of Simplicity in FW/1Power of Simplicity in FW/1
Power of Simplicity in FW/1
 
EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG Germany
 
ColdFusion ORM - Advanced : Adobe Max 2009
ColdFusion ORM - Advanced : Adobe Max 2009ColdFusion ORM - Advanced : Adobe Max 2009
ColdFusion ORM - Advanced : Adobe Max 2009
 
Php MySql For Beginners
Php MySql For BeginnersPhp MySql For Beginners
Php MySql For Beginners
 
Get database properties using power shell in sql server 2008 techrepublic
Get database properties using power shell in sql server 2008   techrepublicGet database properties using power shell in sql server 2008   techrepublic
Get database properties using power shell in sql server 2008 techrepublic
 
Enterprise Manager: Write powerful scripts with EMCLI
Enterprise Manager: Write powerful scripts with EMCLIEnterprise Manager: Write powerful scripts with EMCLI
Enterprise Manager: Write powerful scripts with EMCLI
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
 
Drupal 8 Services
Drupal 8 ServicesDrupal 8 Services
Drupal 8 Services
 
Configure Your Projects with Apache Tamaya
Configure Your Projects with Apache TamayaConfigure Your Projects with Apache Tamaya
Configure Your Projects with Apache Tamaya
 
Spring 4 - A&BP CC
Spring 4 - A&BP CCSpring 4 - A&BP CC
Spring 4 - A&BP CC
 
SQL Cockpit - Releasenotes 3.0
SQL Cockpit - Releasenotes 3.0SQL Cockpit - Releasenotes 3.0
SQL Cockpit - Releasenotes 3.0
 

Andere mochten auch

Cf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipCf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanship
ColdFusionConference
 
Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]
ColdFusionConference
 

Andere mochten auch (20)

Open Yourself to Closures
Open Yourself to ClosuresOpen Yourself to Closures
Open Yourself to Closures
 
Cf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipCf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanship
 
Locking Down CF Servers
Locking Down CF ServersLocking Down CF Servers
Locking Down CF Servers
 
Dont throwthatout
Dont throwthatoutDont throwthatout
Dont throwthatout
 
Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]Single page apps_with_cf_and_angular[1]
Single page apps_with_cf_and_angular[1]
 
Load Balancing, Failover and Scalability with ColdFusion
Load Balancing, Failover and Scalability with ColdFusionLoad Balancing, Failover and Scalability with ColdFusion
Load Balancing, Failover and Scalability with ColdFusion
 
Getting started with mobile application development
Getting started with mobile application developmentGetting started with mobile application development
Getting started with mobile application development
 
PostCSS: A dumb name for an awesome thing
PostCSS: A dumb name for an awesome thingPostCSS: A dumb name for an awesome thing
PostCSS: A dumb name for an awesome thing
 
Who Owns Software Security?
Who Owns Software Security?Who Owns Software Security?
Who Owns Software Security?
 
Mura intergration-slides
Mura intergration-slidesMura intergration-slides
Mura intergration-slides
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
How do I write Testable Javascript
How do I write Testable JavascriptHow do I write Testable Javascript
How do I write Testable Javascript
 
Sql killedserver
Sql killedserverSql killedserver
Sql killedserver
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
Cold fusion is racecar fast
Cold fusion is racecar fastCold fusion is racecar fast
Cold fusion is racecar fast
 
Understanding bdd and tdd with lego
Understanding bdd and tdd with legoUnderstanding bdd and tdd with lego
Understanding bdd and tdd with lego
 
Top5 scalabilityissues
Top5 scalabilityissuesTop5 scalabilityissues
Top5 scalabilityissues
 
Building Software in a weekend
Building Software in a weekendBuilding Software in a weekend
Building Software in a weekend
 
2014 cf summit_clustering
2014 cf summit_clustering2014 cf summit_clustering
2014 cf summit_clustering
 
Locking Down CF Servers
Locking Down CF ServersLocking Down CF Servers
Locking Down CF Servers
 

Ähnlich wie Language enhancements in cold fusion 11

WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Jmorrow rtv den_auto_config_rapidclone
Jmorrow rtv den_auto_config_rapidcloneJmorrow rtv den_auto_config_rapidclone
Jmorrow rtv den_auto_config_rapidclone
Mlx Le
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best Practices
Doris Chen
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Marco Gralike
 

Ähnlich wie Language enhancements in cold fusion 11 (20)

Leveraging the Latest OSGi R7 Specifications - C Ziegeler & D Bosschaert
Leveraging the Latest OSGi R7 Specifications - C Ziegeler & D BosschaertLeveraging the Latest OSGi R7 Specifications - C Ziegeler & D Bosschaert
Leveraging the Latest OSGi R7 Specifications - C Ziegeler & D Bosschaert
 
Play 2.0
Play 2.0Play 2.0
Play 2.0
 
GlassFish REST Administration Backend
GlassFish REST Administration BackendGlassFish REST Administration Backend
GlassFish REST Administration Backend
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Jmorrow rtv den_auto_config_rapidclone
Jmorrow rtv den_auto_config_rapidcloneJmorrow rtv den_auto_config_rapidclone
Jmorrow rtv den_auto_config_rapidclone
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007Language Enhancement in ColdFusion 8 - CFUnited 2007
Language Enhancement in ColdFusion 8 - CFUnited 2007
 
GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012GlassFish REST Administration Backend at JavaOne India 2012
GlassFish REST Administration Backend at JavaOne India 2012
 
SCR Annotations for Fun and Profit
SCR Annotations for Fun and ProfitSCR Annotations for Fun and Profit
SCR Annotations for Fun and Profit
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best Practices
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
Php classes in mumbai
Php classes in mumbaiPhp classes in mumbai
Php classes in mumbai
 
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten ZiegelerOSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...
 
Ext Js
Ext JsExt Js
Ext Js
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Angular Schematics
Angular SchematicsAngular Schematics
Angular Schematics
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 

Mehr von ColdFusionConference

Mehr von ColdFusionConference (20)

Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Cf ppt vsr
Cf ppt vsrCf ppt vsr
Cf ppt vsr
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
API Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIsAPI Economy, Realizing the Business Value of APIs
API Economy, Realizing the Business Value of APIs
 
Don't just pdf, Smart PDF
Don't just pdf, Smart PDFDon't just pdf, Smart PDF
Don't just pdf, Smart PDF
 
Crafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an ArchitectCrafting ColdFusion Applications like an Architect
Crafting ColdFusion Applications like an Architect
 
Security And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API ManagerSecurity And Access Control For APIS using CF API Manager
Security And Access Control For APIS using CF API Manager
 
Monetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APISMonetizing Business Models: ColdFusion and APIS
Monetizing Business Models: ColdFusion and APIS
 
Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016Become a Security Rockstar with ColdFusion 2016
Become a Security Rockstar with ColdFusion 2016
 
ColdFusion in Transit action
ColdFusion in Transit actionColdFusion in Transit action
ColdFusion in Transit action
 
Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016Developer Insights for Application Upgrade to ColdFusion 2016
Developer Insights for Application Upgrade to ColdFusion 2016
 
Where is cold fusion headed
Where is cold fusion headedWhere is cold fusion headed
Where is cold fusion headed
 
ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995ColdFusion Keynote: Building the Agile Web Since 1995
ColdFusion Keynote: Building the Agile Web Since 1995
 
Instant ColdFusion with Vagrant
Instant ColdFusion with VagrantInstant ColdFusion with Vagrant
Instant ColdFusion with Vagrant
 
Restful services with ColdFusion
Restful services with ColdFusionRestful services with ColdFusion
Restful services with ColdFusion
 
Super Fast Application development with Mura CMS
Super Fast Application development with Mura CMSSuper Fast Application development with Mura CMS
Super Fast Application development with Mura CMS
 
Build your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and webBuild your own secure and real-time dashboard for mobile and web
Build your own secure and real-time dashboard for mobile and web
 
Why Everyone else writes bad code
Why Everyone else writes bad codeWhy Everyone else writes bad code
Why Everyone else writes bad code
 
Securing applications
Securing applicationsSecuring applications
Securing applications
 
Testing automaton
Testing automatonTesting automaton
Testing automaton
 

Kürzlich hochgeladen

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Language enhancements in cold fusion 11

  • 1. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Language Enhancements in ColdFusion 11 (Splendor) Ram Kulkarni 1 @ram_kulkarni ramkulkarni.com
  • 2. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Language Enhancements in ColdFusion 11 §  Full CFScript support §  Member functions for data types §  JSON enhancements §  Query functions §  Elvis operator §  Built-in functions as data type §  Collection functions §  Application specific dynamic datasource 2
  • 3. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Tags in CFScript 3
  • 4. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Tags in CFScript §  Can call most tags in cfscript §  Call tags as functions §  Name of the function is same as tag name §  Attributes are passed as name-value pair separated by comma §  Example <cfscript> cfdocument (format="PDF" ,src="report.cfm"); </cfscript> 4
  • 5. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Tags in CFScript– child tags <cfscript>   cfchart ( format="html")   {   cfchartseries (type="bar", seriescolor="##4dc", label="Sales")   {   cfchartdata (item="Jan" ,value="100" );   cfchartdata (item="Feb" ,value="400" );   cfchartdata (item="Mar" ,value="200" );   cfchartdata (item="Aprl" ,value="500" );   cfchartdata (item="May" ,value="700" );   cfchartdata (item="Jun" ,value="300" );   }   }   </cfscript>   5
  • 6. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Tags in CFScript– using writeoutput <cfscript> name = "Ram"; cfsavecontent (variable="var1" ) { writeOutput("<b>"); writeOutput("Hello #name# !<b>"); } writeOutput(var1); </cfscript> 6
  • 7. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Custom Tags in CFScript Call custom tags in cfscript with “cf_” prefix <cfscript> cf_sayHello(name="Ram"); </cfscript> Using imported custom tags <cfimport prefix="hello" taglib="customtags"> <cfscript> hello:sayHello(name="Ram"); </cfscript> 7
  • 8. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Tags not available in CFScript §  cfscript §  cfoutput §  cfdump §  cfinvoke §  cfinvokeargument §  cfobject §  cfset 8
  • 9. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Data Type Member Functions 9
  • 10. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Member Functions for Data Types §  Access functions on data types as member functions Example <cfscript> st = { firstName: "Ram", lastName: "Kulkarni" }; writeDump(st.find("firstName")); //structFind(st,"firstName"); st.append({company:"Adobe"}); //structAppend(st,{company:"Adobe"}); writeDump(st); </cfscript> 10
  • 11. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Supported Data Types §  Array §  Struct §  List §  Date §  String §  Query §  Xml §  Image §  Spreadsheet 11
  • 12. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. JSON Enhancements 12
  • 13. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. JSON Enhancements §  Case of Struct keys now are preserved §  Select option “Preserve case for Struct keys for Serialization” in the Administrator->Settings §  Data types inferred for Query columns and CFC properties §  Option to serialize Query as Struct §  Custom Serializers 13
  • 14. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. JSON Case Sensitivity §  Setting case preservation for Struct keys §  Application Level §  Server Level §  Application.cfc setting component { this.name = "JSONEnhancements"; this.serialization.preserveCaseForStructKey = true; } §  Server setting in ColdFusion Administrator 14
  • 15. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Type of data preserved in CFC and Query §  ColdFusion is loosely typed language §  It infers data type based on value assigned §  But sometime it can get data type wrong e.g. “0123” could be converted to number 123 §  JSON Serialization for Query §  Infers data type from column type of Database §  JSON Serialization for CFC §  Infers data type from ‘type’ attribute of CFC property 15
  • 16. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Serialize Query as Struct §  Before ColdFusion 11 §  serializeJSON (object [,boolean queryFormat]) §  In ColdFusion 11 §  serializeJSON (object [, object queryFormat]) §  Second argument could be §  True, False, “row”, “column”, “struct” §  Application.cfc setting component { this.serialization.serializeQueryAs = "struct"; } 16
  • 17. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Custom Serializer §  New serialize functions §  serialzeXML and deserializeXML §  serializeJSON and deserializeJSON already existed §  Set custom serializer in Application.cfc component { this.customSerializer = "MyJSONSerializer"; } §  Create a CFC for custom serialization and implement following functions – function canSerialize (type) access="remote" returntype="boolean” function serialize (objToSerialize, acceptHeader) access="remote" returntype="String” function canDeSerialize (type) access="remote" returntype="boolean" function deSerialize (objToSerialize, acceptHeader) access="remote" returntype="String" 17
  • 18. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Query Functions 18
  • 19. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. queryExecute §  Syntax queryExecute (sql [,queryParams] [,queryOptions]) §  Examples: <cfscript> rs = queryExecute("select * from employee",[], {datasource:”EmployeeDS”});
 rs = queryExecute("select * from employee where id = ?", [1]);
 rs = queryExecute("select * from employee where id = :empId", {empId:1});
 rs = queryExecute("select * from employee where id = :empId", {empId: {type="integer", value=1}});
 rs = queryExecute("select * from employee where id = :empId and first_name like :firstName", {empId:1, firstName:"Ram"}); </cfscript> 19
  • 20. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. queryGetRow Function §  Retrieves specific query row §  Result is returned as Struct §  Throws RowNumberOutOfBoundException if index is greater than num rows §  Syntax: row = queryGetRow (queryObj, rowIndex) OR row = queryObj.getRow(rowIndex) <cfscript> queryObj = queryExecute("select * from employee order by first_name"); writeDump(queryObj); writeDump(queryObj.getRow(2)); writeDump(queryGetRow(queryObj, 1)); </cfscript> 20
  • 21. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Other Language Enhancements 21
  • 22. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Elvis Operator §  Special case of Ternary operator - ?: <cfscript> var1 = isDefined("var2") ? var2 : "defaultValue"; writeOutput(var1 & "<br>"); var1 = var2 ?: "defaultValue"; writeOutput(var1); </cfscript> Output is the same – “defaultValue” 22
  • 23. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Build-in functions as data types §  Pass built-in function as function argument §  Return built-in function from a function §  Assign built-in function to a variable You could do all of above with UDFs earlier, now supported for built-in functions <cfscript> a = [10, 44, 55, 60]; function arrayOperation (opFunc) { return opFunc(a); } writeOutput("Array Max = " & arrayOperation(arrayMax) & "<br>"); writeOutput("Array Min = " & arrayOperation(arrayMin) & "<br>"); writeOutput("Array Average = " & arrayOperation(arrayAvg) & "<br>"); §  </cfscript> 23
  • 24. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Enhancements to collection functions §  Index and array object arguments added to closure function of arrayEach §  arrayEach(array, function (arrayElement, index, arrayObj) { … }); §  New function listEach §  listEach ( list/String, function (listObj, index){} [, delimiters_string] [, includeEmpltyFields_boolean] ) 24
  • 25. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Enhancements to collection functions - Continued §  arrayReduce §  arrayReduce (arrayObj, function(prevResult,item, index, arrayObj){}); §  Returns a single value §  arrayMap §  arrayMap (arrayObj, function (item, index, arrayObj){}); §  Replaces value of array element at given index and returns new array §  Similarly structReduce, structMap, listReduce and listMap are added 25
  • 26. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Application Specific Datasource §  Ways to create datasource §  In the Administrator §  Using Admin API §  CF11 – New way to create dynamic datasources §  In application.cfc this.datasources.myDataSource = { database = “path_to_folder", driver = "Apache Derby Embedded" }; this.datasource = "myDataSource"; 26
  • 27. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Application specific datasource – continued … §  Creating datasource using JDBC URL this.datasources.dsn2={"driver"="MSSQLServer", url="jdbc:macromedia:sqlserver://localhost MSSQL2008;databaseName=regression;;sendStringParametersAsUnicode=false;querytimeout=0;M axPooledStatements=1000","username"="sa","password"="pass"}; §  In case of clash, Application datasource will get preference 27
  • 28. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. CFZip Enhancements §  Support for password protected zip files §  CFZip – added two attributes §  password §  encryptionAlgorithm – Standard, AES-128, AES-256 (default) <cfscript> cfzip (action="zip", file="C:ZipTesttestzipfile.zip", source="C:ZipTestsample.txt", password="pass"); cfzip (action="list", name="zipFileList", file="C:ZipTesttestzipfile.zip"); cfzip (action="unzip", file="C:ZipTesttestzipfile.zip", destination="C:ZipTest", password="pass", overwrite="true"); </cfscript> 28
  • 29. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. CFZip Enhancements §  Can specify password for individual files <cfscript> cfzip(action="zip", file="C:ZipTesttestzipfile.zip", overwrite="true") { cfzipparam(source="C:ZipTestsample.txt", password="pass"); }; cfzip(action="unzip", file="C:ZipTesttestzipfile.zip", destination="C:ZipTest", overwrite="true") { cfzipparam(source="sample.txt", password="pass"); }; </cfscript> 29
  • 30. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Thank you 30
  • 31. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.