Entries Tagged as "CFML"

Presenting Railo Extension Builder!

At CFcamp 2012, me and Mark Drew did a presentation about Railo extensions, and the Railo Extension Builder. Right there, we released the first public version of Railo Extension Builder.
In case you weren't there, this blog post is a short recap of the presentation. The original slides can be found on slideshare.

4 Comments

Railo tip: multiple assignments in one

While waiting for CF.Objective() to begin, I am doing some relaxed coding with Micha in the lobby of our hotel. It's great to be talking about and working on Railo with the main man :-)

Anyway, a new Railo tip:

<cfscript>
paul = micha = new Person();
paul.name = 'Paul';
micha.name = 'Micha';
dump(variables);
</cfscript>

See the highlighted part? You can do multiple assignments in one statement!

It also works in regular CFML off course:

<cfset paul = micha = new Person() />

 

No Comments

Railo awesomeness: some cool functions and options

I've been working with the Railo source code all day, and noticed some cool functions within the code. I'm taking a minute to share 'em...

querySlice(query, startrow, rowcount)

This function returns a part of the original query, defined by the startrow and rowcount.

Documentation: http://wiki.getrailo.org/wiki/FUNCTION:QUERYSLICE

Example code:

<cfset q = querynew('column1') />
<cfset queryaddrow(q) />
<cfset querysetcell(q, 'column1', "this is row 1") />
<cfset queryaddrow(q) />
<cfset querysetcell(q, 'column1', "this is row 2") />
<!--- this will dump query 'q', but only containing row 2! --->
<cfdump var="#querySlice(q, 2, 1)#" abort />

isZipFile(filepath)

Return yes/no whether the given file path is a zip file.

Documentation: http://wiki.getrailo.org/wiki/FUNCTION:ISZIPFILE

Example code:

<cfzip action="zip" source="/" file="testZip.zip" recurse="no" />
<cfoutput>
isZipFile('testZip.zip'): #isZipFile('testZip.zip')#<br />
isZipFile( getCurrentTemplatePath() ): #isZipFile( getCurrentTemplatePath() )#
</cfoutput>

someObject["set#key#"](value)

This might also be possible (?) in the most recent versions of other CFML engines, but I sure missed it when I worked with Coldfusion 7 and 8.

When you need to update values in a CFC (bean or valueObject) by calling it's setters, but you don't know beforehand which values you need to set, then I always had to use <cfinvoke>:

<cfinvoke component="#someObject#" method="set#key#">
<cfinvokeargument value="#value#" />
</cfinvoke>

Railo allows you to use struct notation:

<cfset someObject["set#key#"](value) />

Now that's a bit shorter and cleaner!

No Comments

Railo 3 for beginners book now pubished!

railo book coverMark Drew, CEO of Railo Technologies Ltd in the UK, decided to write a book about Railo. When his idea got accepted by publisher PacktPub, he asked the rest of the Railo team if we wanted to write one or more chapters as well. I immediately said yes, and then found out that even writing one chapter of a book takes a huge effort. So I researched, I wrote, and even learned some new stuff while I was writing. It was a great experience to write for something that I am already passionate about. Trying to make the reader enthusiastic, while not being too techy all the time, was a nice challenge.

Mark, and also Gert Franz and Jordan Michaels, did a great job there! The book is absolutely a must-read for anyone using Railo, and wanting to learn about Railo! It not only covers CFML basics, but goes into all areas to get the most out of Railo Server.

Read more about, or buy the Railo 3 for beginners book at packtpub.com!

No Comments

Adding cftransactions to prevent deadlocks in SQL Server

I recently had to dive into errors from one of our most busy web applications. The errors came from SQL Server, saying "Transaction (Process ID 51) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.".

This error comes from SQL Server, and more or less says "I could not execute your query, because it got in the way of another query". Veeery simply said, I know.

First thing I did, was asking the Railo team whether we could create a new option in the datasource screen "retry deadlocked query", with a number indicating the maximum number of retries. Initial reactions were positive, so I added a feature request into the Railo JIRA.

But, problem still remains for now. In my situation, it was always a SELECT query which was chosen as the deadlock victim. Now, I did a lot of googling and reading about preventing or circumventing this problem, and the most common answer was "use Read Uncommitted with your select statements, if you don't mind dirty reads". After discussing a bit at the office, we decided we don't mind, since we couldn't think of a really problematic scenario with it.

So, we had to change all select queries from...

6 Comments

grouping