Entries Tagged as "Railo"

Railo tip: get a query's columnlist case-sensitive

A member of the Railo mailing list asked if he could get the columnlist of a query object case-sensitive. Because #queryObject.columnlist# always returns it uppercase.

One good answer was to look at #getMetaData(queryObject)#, which returns an array with structs with keys isCaseSensitive, name, typeName.
So that's an option, to just loop over that array.

But I knew it must be easier, so I looked in the Railo source code, and found this simple solution:

<cfset caseSensitiveColumnList = queryObject.getColumnlist(false) />
<cfset upperCaseColumnList = queryObject.getColumnlist() />

Pretty cool eeh? Start using Railo today!

NOTE: see the comments underneath; if you typed the actual column names in the SELECT statement, like in "SELECT userID, userName from users", then the case you used there will be returned. But if you used "SELECT * from users", then the actual table column names are returned.

7 Comments

Railo tip: use a custom function for the cfdirectory "filter" attribute

While searching for something else which had to do with cfdirectory, I saw a lot of questions about the filter attribute of cfdirectory. With this attribute, you can filter the results by extensions or part of the file/directory name. For example "*.gif".

The first question that a lot of people have, is whether they can use multiple file filters. The answer is: Yes. You just need to delimit the file filters by a pipe character, like this: "*.gif|*.jpg|*.png".

Another question was whether you could disallow some files or directories from the listing. Now that's much more complicated, or at least you need to write some extra lines of code to remove these from the original directory listing...

Except on Railo! Because with Railo, you can use a custom function as the filter argument, like this:

<cfdirectory action="list" directory="/test/" recurse="true" name="qFiles" filter="#theFilter#" />
<cfdump var="#qFiles#" />

<cffunction name="theFilter" returntype="boolean">
<cfargument name="fullpath" type="string" />
<!--- disallow a certain directory --->
<cfif refindNoCase("[/\\]DisallowedDirectory[/\\]", arguments.fullPath)>
<cfreturn false />
<!--- allow certain extensions --->
<cfelseif refindNoCase("\.(swf|jpe?g|gif|png)$", arguments.fullPath)>
<cfreturn true />
<cfelse>
<cfreturn false />
</cfif>
</cffunction>

As you can see, the function returns a boolean value "true" or "false". True means that the file or directory will be included into the listing, and when False, it will not.

Pretty cool eeh! Start using Railo today ;-)

By the way, when you test this code on ACF 8 or 9, it does not throw an error, but instead just returns zero records.

5 Comments

RegexSafe() function for coldfusion

It will probably already be out there somewhere, but I couldn't find it: a function which makes a string regular-expression-safe to use.

[Skip skip delete remove etcetera]
Edit 15 nov. 2010: See Peter Boughton's comment underneath; the function I thought of could have been made a LOT simpler, so I am just posting his much appreciated code here:

<cffunction name="regExSafe" returntype="string" access="public" output="no">
<cfargument name="text" type="string" required="yes" />
<cfreturn rereplace(arguments.text, "(?=[\[\]\\^$.|?*+()])", "\", "all") />
</cffunction>

Thanks Peter!

Have tested this on ACF 8 and Railo 3.2.0.001.

3 Comments

Railo admin plugin: Log analyzer version 2.2.0

When I told Gert Franz from Railo that it was a pity that there was no log viewing option in the Railo admin, he smiled and showed me a log analyzer plugin which he already wrote. "But it's still in development, so we haven't published it yet", he said.

The plugin indeed lacked some options, but not anymore! I added the remaining options, and now made it available to everyone via my extensionProvider.
It shows you the logs from the web admin, ordered by error message, last occurence date, or amount of occurences. And you can off course download the log file.

47 Comments

How to add mod_jk to Apache for Tomcat (+Railo!)

After finding out how I could use mod_jk for my Apache and Tomcat install, I found out that using mod_proxy does almost the same (it also uses AJP13). This last one is much more easy to setup, but it is only available for Apache 2.2 and later.

So here you will find the instructions for setting up mod_jk, even though I would suggest to just use the mod_proxy code if you are on Apache 2.2. I also included that setup underneath.

9 Comments

denominative-lowborn