Sorcerer's Tower

Entries tagged "ColdFusion"

Adobe ColdFusion is a RAD application development platform on the JVM.

Find out more at adobe.com/coldfusion

Found 5 entries tagged with "coldfusion".

CFML on Wikipedia

If you've ever looked at the CFML related articles on Wikipedia, you can't fail to have noticed that, especially when compared to other programming articles, they're not very good.

When somebody puts "coldfusion" or "cfml" into Google, they will almost certainly see the respective Wikipedia pages amongst the top three results, but when they follow those links they're unlikely to get a very good impression!

Not only could both these pages themselves benefit significantly from being cleaned up and improved, but there are only a few frameworks and tools that even have pages, and most of what does exist are very unencyclopaedic stubs. And this doesn't even consider the generic programming pages that often don't even mention CFML.

Take a look at the CFML category page - does that category contain everything you would expect an encyclopaedia to cover about CFML? Check the pages for the frameworks you are familiar with - do they go into the level of detail you would expect, and tell you everything you'd want to know if you were entirely new to CFML?

If you agree that the CFML presence on Wikipedia can and should be improved, and it's up to the CFML community to do it, then read on to find out how you can help fix it.

Introducing the cfRegex Project!

The cfRegex project is two things. Firstly, it is a complete regex implementation for CFML, providing more functionality, flexibility, features and power than the existing CFML RE functions. Secondly, it is a drive to encourage people to properly learn and make use of regex.

Regex is a very flexible language for matching patterns within text, and it has the power to greatly simplify certain programming tasks. However, it can also be intimidating to people not experienced with it.

This problem can be compounded by the relatively limited support for regex in CFML, which often means code is written that is more complex than should be necessary.

cfRegex helps to address both these problems. It provides a number of functions and features that help to reduce the amount of code which programmers have to write, whilst also helping to make their code clearer and easier to understand. In addition, the project provides documentation, not just for its own features, but also for regex itself, helping people to understand exactly what their expressions are matching, and how to get the most out of regex.

Whilst cfRegex is still at a relatively early stage, it is currently usable, and if you're a fan of regex it is certainly worth checking out.

It currently runs on CF 9.0.1, OpenBD 2.0, Railo 3.2 and later.
(Support for CF8 and others will be considered if enough people need it.)

The documentation should tell you everything you need to know about using it, but if not then get it touch and say what's missing so it can be fixed!

If you get stuck, there's a mailing list where you can receive answers to any problems or questions you have.

Java RegEx Utilities - v0.7 preview

Java RegEx Utilities, or jre-utils, is a CFC which provides a convenient way to access Java's regular expression functionality.

Whilst ColdFusion, Railo, and openBD are all built on Java, and CFML does have regular expression functions, they do not actually use the Java regular expression engine, which supports many useful regex constructs.

The purpose of jre-utils is to provide this extra power to CFML developers in a familiar and easy to use way.

I will shortly be releasing v0.7 of jre-utils, which adds a number of new functions, as well as making things more consistent, so I decided I would give this quick preview of what it contains.

expandPath bug in CF8

I've just encountered a very annoying bug with the expandPath function in CF8.

Take the following code:

<cfset MyDir = "."/>

<cfloop index="i" from="1" to="5">
    <cfset MyDir = expandPath(MyDir)/>
    <cfoutput><br/>#MyDir#</cfoutput>
</cfloop>

Run the code through Railo and you will get exactly the right behaviour, with the current directory output five times:

C:\dev\scratch
C:\dev\scratch
C:\dev\scratch
C:\dev\scratch
C:\dev\scratch

Now go run the same code with CF8 - and this is what you get:

F:\ColdFusion8\wwwroot\scratch
F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch
F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch
F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch
F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch

It simply stacks the current directory onto the front each time. Very frustrating.


In order to get round this, I created a regular expression to pull off the last value of any directory containing more than one colon - this will work for Windows machines, but may need to be changed for Linux or MacOSX machines (if the bug affects these).

<cfif isDefined('Server.ColdFusion.ProductName')
    AND Server.ColdFusion.ProductName EQ 'ColdFusion Server'
    AND ListLen( MyDir ,':') GT 2>
    <cfset MyDir = REreplace( MyDir , "^.*([A-Z]:[^:]+)$" , "\1" )/>
</cfif>

Java RegEx Utilities

I have just released Java RegEx Utilities on RIAForge, which is a CFC enabling easy access to Java Regular Expression functionality, adding to what is available in the standard CFML functions.

Currently there are two main functions.

jre.get(Text,RegEx) returns the matches to the regular expression as an array.

jre.replace(Text,RegEx,Replacement) is similar to REReplace, but the Replacement argument can be a function pointer, allowing you to process the results of a regex match with a function

You can find more usage details on the jre-utils wiki, which I plan to update with some examples of when each of these functions can be useful.

I have tested jre-utils against Railo 2 and CFMX 7, but it should also work with ColdFusion 8 and the Java version of BlueDragon - if anyone can test/confirm this please let me know.

Download Java RegEx Utilities from RIAForge.