| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Sep | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Thought I would blog about this, as it wasted almost 2 hours of my time trying to get to the bottom of it.
I was using CFFLUSH on a work project and ColdFusion was returning the following error message:
“You have called cfflush in an invalid location, such as inside a cfquery or cfthread or between a CFML custom tag start and end tag.“
What was confusing, was that there were no CFQUERY, CFTHREAD or Custom Tags in the code!
The problem turned out to be an output=”false” attribute on a component function, which called the function containing the CFFLUSH. This is obvious with hindsight, however the error message sent me on a wild goose chase
ColdFusion 8 added the ability for objects to be serialized. Although you can not serialize/un-serialize objects with CFML, you can use underlying Java functions to do so as described by Pete Freitag’s post Serializing CFC’s in ColdFusion 8. In this post a commenter asked whether there is a use-case where this ability would be useful. While contemplating a problem at work, I think I may have found one.
The problem involves building an asynchronous process queue which sits between a “real-time” web service and the system’s database. The web service will be used to import large amounts of data and the queue is required due to the length of time required to process and then store the data in the database. The idea is to store the data, which will be in the form of CFML beans, in an array in application scope and then have a CFTHREAD process the beans into the database.
Where does serialization come in? Well suppose something happens to the server while there are items in the queue. A restart will lose all the data in the queue. Although this is an edge case, the data is critical to the business and cannot be lost. So, when an item is added to the queue it is serialized and stored to the file system. When an item is removed, the serialized file is removed. On start up, any serialized files on the file system are read and the queue is repopulated without data loss.
This is purely theoretical at this point, but I think the idea has enough merit to give it a try.
This is technique I have been using for a while to handle environmental (development, test, production etc) configuration settings. It mimics the Application.cfc added in ColdFusion 7, creating a Server.cfc shown below.
[The requested file http://www.bealearts.co.uk/wordpress/wp-content/uploads/2008/01/server.cfc could not be found]
The Server.cfc is copied to the approot/webroot of the server and the variables.environment property set the the server type e.g. "Development". Then in each Application deployed to the server, the following code is added to the begining of the onApplicationStart method in Application.cfc.
[The requested file http://www.bealearts.co.uk/wordpress/wp-content/uploads/2008/01/run-server-cfc.cfm could not be found]
Environmental configuration changes within each application can then be made by referencing the server.environment and server.name properties of the server scope.
Many True Type Fonts (TTF) are made up of multiple .TTF files. One file will be for the normal font, while another file is for the Bold version of the Font. For example, the Verdana font that comes with Windows XP consists of four separate files.
The following code shows how to include multiple TTF files into a Flex CSS file.
@font-face{src:url("font/verdana.TTF");font-family: EmbeddedVerdana;font-weight: normal;font-style: normal;}@font-face{src:url("font/verdanab.TTF");font-family: EmbeddedVerdana;font-weight: bold;font-style: normal;}@font-face{src:url("font/verdanai.TTF");font-family: EmbeddedVerdana;font-weight: normal;font-style: italic;}@font-face{src:url("font/verdanaz.TTF");font-family: EmbeddedVerdana;font-weight: bold;font-style: italic;}Application{font-family: EmbeddedVerdana;}The Flex docs tell you that in order to use Fade effects with Text controls, you have to embed a True Type Font to use in the Flex application. The default Fonts available within Flex (Aerial, Verdana etc) will not fade.
This also applies to rotating Flex controls, which is not mentioned in the docs - as far as I can see.
I attended this years Scotch of the Rocks with a press pass from Fusion Authority, and they have just published the articles that I and fellow "member of the press" Kola Oyedeji wrote as reviews of the conference.
Read them at A Tale of CFML, Flex and a Pineapple and A Review of Scotch on the Rocks 2007 respectively.
The Flex Button control provides the means to add an icon to the button, in one of several states disabled/hover etc. However it does not automatically provide a disabled version of the icon you add for its normal enabled state. i.e. A "grayed out" version, which most other visual RAD tools would provided.
After hacking around in the Flex SDK, I found the following code which accomplishes this;
// Fade Disabled Icon DisplayObject(this.getChildByName("disabledIcon")).alpha = 0.4;
This could be used as follows to produce an EditButton class;
<?xml version="1.0" encoding="utf-8"?> <mx:Button xmlns:mx="http://www.adobe.com/2006/mxml" icon="@Embed('EditButton.png')" label="Edit" creationComplete="init();" > <mx:Metadata> [IconFile("EditButton.png")] </mx:Metadata> <mx:Script> <![CDATA[ private function init():void { // Fade Disabled Icon DisplayObject(this.getChildByName("disabledIcon")).alpha = 0.4; } ]]> </mx:Script> </mx:Button>
As I believe this to be a very valuable behavior, I have created a new IconButton Flex Component class to download, which provides a Button control which does automatically provided a disabled version of its main icon.
I have just installed my first Railo CFML Engine in a production environment.
There was a problem with changing the licence from Community to Profressional. So I emailed Railo and within minutes they came back with a custom solution to my problem.
Now thats what I call Customer Service!!
ColdFusion Query of Queries does not natively support OUTER JOINs. The following code demonstrates a work around to perform a LEFT OUTER JOIN between two CF queries, QueryA and QueryB.
i.e. To do this;
SELECT * FROM QueryA LEFT OUTER JOIN QueryB ON QueryA.ID = QueryB.ID
One can use;
<cfquery name="joinQuery" dbtype="query" > SELECT * FROM QueryB WHERE QueryB.ID = -1 </cfquery> <cfset QueryAddRow(joinQuery) /> <cfquery name="result" dbtype="query" > SELECT * FROM QueryA, QueryB WHERE QueryA.ID = QueryB.ID UNION SELECT QueryA.*, joinQuery.* FROM QueryA, joinQuery WHERE QueryA.ID NOT IN (#ValueList(QueryB.ID)#) </cfquery>
A common use of an OUTER JOIN is to find the non-matching records between two record sets, a so called NULL Based OUTER JOIN.
e.g.
SELECT * FROM QueryA LEFT OUTER JOIN QueryB ON QueryA.ID = QueryB.ID WHERE QueryB.ID IS NULL
This situation can be more efficiently implemented in Query of Queries by using the following technique;
SELECT * FROM QueryA WHERE QueryA.ID NOT IN (#ValueList(QueryB.ID)#)
After much experimentation, I have finally managed to get Microsoft SQL 2005 Mirroring with automatic failover working with ColdFusion MX 6/7.
The following steps describe how to setup ColdFusion.
| CF Data Source Name | XXX |
| JDBC URL | jdbc:macromedia:sqlserver://192.168.1.XXX:1433; databaseName=XXX;SelectMethod=direct; sendStringParametersAsUnicode=false; MaxPooledStatements=1000; AlternateServers=(192.168.1.XXX:1433) |
| Driver Class | macromedia.jdbc.MacromediaDriver |
| Driver Name | SQL 2005 |
| User Name | XXX |
| Password | XXX |
You should now be able to manually failover the mirrored database and, after an initial ColdFusion connection reset error, your application to run as normal.
Simple when you now how!