ColdFusion Singletons
Singletons are perhaps one of the most simple Design Patterns. For those who don't know sigletons are a class that can only have one instance. They can be thought of as a glorified global variable - but are a lot more useful.
Most ColdFusion classes, or rather instances of CF components, can be turned in a singleton by placing the following code in your Application.cfm:
2 <cfset application.<instance name> = createobject("component",<path to component>)>
3 </cfif>
or OnApplicationStart method of your Application.cfc:
ColdFusion hCard Microformats Custom Tag
I a huge fan of of microformats (or µF), if you're not familiar with them take a look at www.microformats.org and the entry at Wikipedia.
Basically it's a way of marking up HTML to give it more more meaning, think of it as the semantic web (with a small s) that is available now.
hCard is a HTML representation of vCard and while no browers currently support it natively, the next versions of Firefox and IE will support it. There are also plugins currently available for Firefox (Operator and Tails ) and Safari (various bookmarklets) and IE (various favlets).
Flash Internationalization and Flash Fonts (part1)
Lets see how we can use the code in my previous article on internationalization and apply it to a flash fla.
Here's a flash file we want to convert: static fla(28K), static swf(12K), currently all of the text inside the fla is static text.
First we need to create some xml files containing the content in the languages we want English and French and Japanese.
ColdFusion Securely Storing Passwords
Consider the following code that implements a simple login.
2select * from users
3where name = '#form.login#' and password = '#form.password#'
4</cfquery>
5
6// if login failed go back to login page
7<cfif user.recordcount is 0>
8 <cflocation url="login.cfm">
9</cfif>
One of the issues with this is that the password is stored in the database as plain text. Anything with access to the database (including your ColdFusion application) could possibly be used to get a list of all users and their passwords.
Flash Internationalization
Flash has good support for internationalization but it does have a few restrictions such as you need to recompile your fla if you add a new language.
I've come up with a fairly simple way to load languages from XML files and to support the following:
- Language defaults to the users language
- Language can be set via a URL parameter
- New languages can be added after the swf is deployed
ColdFusion Simple Friendly URLs
There quite a few methods out there for making search engine and user friendly URLs in ColdFusion eg Spike's Friendly URL servlet or one of the many Apache and IIS URL rewiters.
These are great if your hosting provider has installed them or if you have your own dedicated server. So what do you do if this is not the case or you want to support friendly URLs in a web server agnostic way?