Skip to main content

Posts

ColdFusion 10: REST settings in Application.cfc

There are a couple of variables that have been introduced in Application.cfc which are REST specific. These are this.restsettings.cfclocation and this.restsettings.skipCFCWithError . If you have a list of directories containing REST enabled CFCs then you can specify the same in the variable this.restsettings.cfclocation. At the time of registration, the specified directories and its subdirectories will be scanned for REST enabled CFCs and then deployed. If any of these CFCs contain compilation errors then an error is thrown and the registration would fail. To tackle this another variable this.restsettings.skipCFCWithError is provided. When set to true, the CFCs with compilation errors would be skipped. Only those without any compilation errors would be deployed successfully.

ColdFusion 10: onAbort and onRequestEnd behavior

Today, I wrote a post on the new lifecycle method - ‘onAbort’, which can be defined in an Applicaiton.cfc file . It is invoked when the cfabort tag is executed. David Boyer , asked me whether the onRequestEnd method is also invoked on executing the cfabort tag. In CF 9.0.1 it did invoke the onRequestEnd method. See Ben’s post: http://www.bennadel.com/blog/2221-CFAbort-And-OnRequestEnd-Behavior-In-ColdFusion-8-And-ColdFusion-9.htm Now in CF 10, this behavior has changed. The onRequestEnd method is no longer invoked when cfabort, cflocation or cfcontent tag is executed. The onAbort handler method defined in Application.cfc file would be invoked on executing these tags. Also, the onRequestEnd method would not be invoked even if the abort handler(onAbort) is not defined in Application.cfc.

ColdFusion 10 : onAbort method in Application.cfc

I was experimenting with a new method 'onAbort' introduced in ColdFuion 10 which can be defined in an Application.cfc file. This method is invoked when cfabort is called. What if showerror attribute is also present in the cfabort tag? Would it still invoke the onAbort method and then onError? The onAbort method would be ignored and the onError method would be invoked. Even in a case wherein the onError method is not defined in Application.cfc, the onAbort method wouldn't be invoked. In this case the error message would be shown on the standard error template.

ColdFusion 10: Returning Complex data from a REST service

There are various complex types in ColdFusion – Array, Struct, Query. When a REST service in ColdFusion returns one of these complex types, it has to be serialized to either JSON or XML format. As explained in my previous post , the HTTP protocol can be used in content type negotiation. You can specify the desired content type either by specifying it at the end of the URL or in the Accept header of HTTP request. In this post, I’ll explain the format in which the complex types are returned from a ColdFusion REST service.

ColdFusion 10: CFFILE - Specifying file content in the tag body

Prior to ColdFusion 10, to write or append to a file one had to specify the file content in the output attribute of CFFILE tag. In ColdFusion 10, you can specify the file content in the body of the cffile tag. In cases where the file content is specified in body as well as in the output attribute, the output attribute would be ignored.

ColdFusion 10: Geo-location on a Google map created with CFMAP tag

In ColdFusion 10, you can now show the users location on a Google map created with the CFMAP tag. The CFMAP and CFMAPITEM tags now have a boolean attribute showuser . When set to true the browser would ask for the users permission and then display users geo-location on the map. This is now supported in most of the modern browsers. In cases where the browser doesn’t support Geo-location API then the values provided in centeraddress or centerlatitude\centerlongitude attributes will be used to add a marker in the Google map.

ColdFusion 10: HTTP Content Negotiation + REST– Part 2

Following with my previous post on how content negotiation between the client and server help in invoking an appropriate REST service. In this post I’ll explain how one can specify multiple mime types in the request header and also the quality factor that enables server to decide which mime type to serve for the incoming request. The client sends a HTTP request to the Server along with several headers, one of them is the Accept header. The Accept header can contain a list of mime types that the client (user agent) is willing to process. These mime types are separated by a comma and may optionally be combined with the quality factor. A CFC can contain several methods with produces attribute set to a specific mime type. The Accept header may contain several mime types: text/html, text/plain, application/xml, application/json, */* Server would parse the Accept header and will search for a REST service that matches the mime type specified first in the Accept header list. In this cas