Monthly Archives

Categories

Other Blogs

Search

Subscribe

Vykin Corporation (company based in Florida, but position is in Iraq) is looking for a ColdFusion and Flex developer with secret security clearances for the US Department of Defense in Iraq. Requirements include ColdFusion and/or Flex certification. Details posted online.

Unnamed client (KS) is looking for a ColdFusion developer for a contract to permanent position. ColdFusion 8 experience required, as is experience with Flash. Contact Melissa Kelly-Foxhoven at recruiter PAiGE Technologies, LLC.

NxStage Medical, Inc. (Lawrence, MA) is looking for a ColdFusion developer. Requirements include knowledge of HTML, CSS, JavaScript, XML, and SQL, and a solid understanding of procedural and object-oriented code. Familiarity with framework-driven development environments, and Flash development, a plus. Contact Duane Dumont.

Last night I presented ColdFusion, Flex, and more to a joint meeting of the local Flex and ColdFusion groups. The group took a little while to warm up, but then really got going. The session ran over 2 hours and was highly interactive.

Big winners were spreadsheet integration, ORM, Bolt extensions, and the data connectivity in Flash Builder 4. We also got into a lively and heated tangent conversation about the AS3 server proof-of-concept shown during the MAX sneaks last year (the crowd was lobbying heavily to turn this into a product).

Fellow Adobe Platform Evangelist (and recent ColdFusion devotee) Greg Wilson has created tBlurb.com, an app that lets you enter code and get a short URL to it for sharing (you can choose your own or let it pick it for you). The app features a rich text editor, and supports ActionScript, C++, C#, ColdFusion, CSS, Delphi, Java, JavaScript, PHP, Python, Ruby, SQL, VB.NET and XML/HTML. And Greg built it all in ColdFusion!

I am in San Francisco for a few days of meetings, video shoots, and more (almost all MAX 2009 related). But tonight I'll get to do what I really enjoy doing, presenting to our usergroups. I'll be presenting ColdFusion and Flash Builder futures to the BACFUG group this evening at 6:30pm in the Adobe San Francisco office (601 Townsend). Details posted online.

Last week I posted an entry on the spreadsheet support planned for ColdFusion Centaur. That post (unsurprisingly) generated lots of questions and comments, and so I thought it worthwhile to post a bigger and more sophisticated example, this time building a new spreadsheet from scratch.

We'll start with a simple Application.cfc to define the datasource needed for this app:

ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org<cfcomponent> <cfset this.datasource="cfartgallery"></cfcomponent>1<cfcomponent>2<cfset this.datasource="cfartgallery">3</cfcomponent>

ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org<!--- Get data ---><cfquery name="ArtOrders">SELECT orderid, customerfirstname, customerlastname, totalFROM ordersORDER BY orderid</cfquery>

That's all it takes. <cfspreadsheet> creates a spreadsheet populated with the retrieved data, using the query column names as column headers in the first spreadsheet row, and the data starting in the second row. Nice, huh?

But what if you want more control? What if you want to explicitly control data placement? What if you needed to provide row or column or cell level formatting? And what if you needed a total cell containing a formula to SUM the total column?

ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org<!--- Get data ---><cfquery name="ArtOrders">SELECT orderid, customerfirstname, customerlastname, totalFROM ordersORDER BY orderid</cfquery>

Once again, we start with a database query. Then, SpreadsheetNew() is used to create a new spreadsheet object.

The code then creates the header row. SpreadsheetAddRow() is used to add a specific row, the column headers (as no row number was specified, SpreadsheetAddRow() adds the row to the next free row, the first). SpreadsheetFormatObject() is then used to format row 1, this function accepts a structure (which here is implicitly created inline).

Next comes the data. SpreadsheetAddRows() adds the entire query to the spreadsheet (again, as no row was specified the data gets added to the next free row).

Now for the formula which will total all orders. So as to not hard code the row, a few <cfset> statements are used to calculate the first and last data row, and the row for the total (2nd row after the end of the data, so leaving one empty row in between data and total). The formula too can't be hard coded, so instead of SUM(D2:D24), the row variables are used to build the formula string dynamically. SpreadsheetSetCellValue() is used to add a title, and SpreadsheetSetCellFormula() inserts the formula.

Next, the entire fourth column, containing the order amounts and the calculated total, is formatted to display as currency using SpreadsheetFormatColumn().

All that is left to do then is to save the file using <cfspreadsheet>.

<cfspreadsheet> and its 30+ supporting functions can do lots more, but this should give you a taste of just what's possible using this innovative new feature.

My Sams Teach Yourself Regular Expressions in 10 Minutes has proven to be a very popular book, and tens of thousands of developers have used it to get started with Regular Expressions. The book teaches RegEx incrementally, and for each example a block of text is used, and matching text is shaded to clearly demonstrate what the Regular Expression is doing.

ColdFusion can execute code when an application starts and ends, when a session starts and ends, when a request starts and ends, and more. But what if you need to execute code when a server starts up? Granted, this is not a common use case, but when needed, we've had to use onApplicationStart for this, probably doing something like:

ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org<cfif not IsDefined("SERVER.myVar")>...</cfif>1<cfif not IsDefined("SERVER.myVar")>2...3</cfif>

By default this is a method named onServerStart in server.cfc. But, actually, it can be in any ColdFusion Component, including an Application.cfc. In ColdFusion Administrator you can point to the CFC and method to be invoked, and ColdFusion will execute the code on server start-up before processing any requests.

In the above snippet, two variables are created. The first variable uses the var keyword to ensure that the variable is local to the function, and if the same variable name existed elsewhere it won't be overwritten. The second variable does not use var, and as such is not local, and variable conflicts can indeed occur. And so, when creating user defined functions or ColdFusion Component methods, the rule has always been to always prefix local variables with "var".

But what exactly is a var variable? What scope is it in? And how is it accessed using explicit scope notation? The answers to these questions are somewhat unclear, partially because the local var scope is not used like any other ColdFusion scope which is always designated by using a scope prefix (VARIABLES.myVariable, FORM.myVariable, SESSION.mayVariable, etc.).

ColdFusion Centaur simplifies the use of local scopes (without breaking existing code) by explicitly defining a local scope that it intuitively named LOCAL. Here is the same local variable set above, but using the LOCAL scope instead of var:

ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org<cfoutput>#LOCAL.mySafeVariable#</cfoutput>1<cfoutput>#LOCAL.mySafeVariable#</cfoutput>

It's clean, it's simple, it's intuitive, and it's fully backwards compatible. And yes, if you have a variable named "local" it'll still work, the variable will just become LOCAL.local, and as the LOCAL scope is in the default evaluation chain it'll just work.

Oh, one other change. The "var" keyword used to only be supported at the top of functions and methods, so all local variables had to be defined upfront. This limitation has been removed in ColdFusion Centaur (and I actually have mixed feelings about this, but so be it).

ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org<cfcomponent> <cfset this.datasource="cfartgallery"></cfcomponent>1<cfcomponent>2<cfset this.datasource="cfartgallery">3</cfcomponent>

In ColdFusion Centaur you can now specify an application wide default datasource by setting this.datasource in Application.cfc. The specified datasource becomes the default for all <CFQUERY>, <CFSTOREDPROC>, and other tags that expect a datasource to be specified. Of course, datasource can still be specified manually if needed, and a specified datasource will override the application default one.

This is one of those duh! enhancements that just makes sense. And, as I'll explain in an upcoming post, it also has another important purpose.