Ever wish you could just install a frequently used UDF to the server since you use it so much? Take any of the numerous UDFs found at CFLib.org for example. How about... QueryRowToStruct()? That's a pretty useful function. Wonder why they didn't build this in? With Railo 3.1 RC, you can build this in yourself. With this blog post, I'm going to outline two different installation concepts, server wide and local context.
First, server wide:
- Click on the "Download" link on QueryRowToStruct and you'll be prompted to download QueryRowToStruct.cfm
- For server wide installation, you'll want to put this in the following directory:
{railo installation directory}/lib/railo-server/context/library/function/ - Restart the server (I had to, I'm going to verify if this step is really necessary or if it can be fixed :) )
Once installed, I shouldn't have to cfinclude or copy/paste that function anywhere. I can create a test.cfm in my localhost and run the example code on QueryRowToStruct description page.
Now, you may be in a particular situation where you can't have this server-wide because you share the server with other people or because there's a conflict. You could just install it to your local context. Each virtual host you make should have its own WEB-INF directory, so you have a global admin and a local admin.
You would repeat all of the steps above, except for #2, you'll want to install this here instead:
{your website root directory}/WEB-INF/railo/library/function/Remember, you don't have to use anything specific from CFLib.org. You can write your own user defined function or install the one that you frequently use. I bet this makes you wonder if Railo 3.1 could give you the ability to create your own Built-In-Tag? ;) You can and there's been some changes, so I plan on investigating and outlining in a new blog post. If you want to see if you can figure it out for yourself, you can use Andrea Campolonghi's <cfajaxproxy> as a great example. This example includes installation directions and will only work on Railo 3.1.020 build or higher.
Update: The resin webserver doesn't need to be restarted, but the Railo servlet engine does. You can do this one of two ways, log into the admin portal and click Restart or via code: <cfadmin action="restart" type="server" password="serverPassword">