n42 Designs

Custom Web Development

SVN, Apache, and Mod_caucho, Oh My

| Comments

I recently set up a new Viviotech VPS and ran into an issue that was easy to fix once I realized what was happening, but difficult to debug.

I set up Railo running on the Resin server using Apache as a front end with mod_caucho. In my httpd.conf file I had the following lines:

This causes Resin to handle all requests from apache. The resin configuration files tell resin which URLs to handle. I also had an SVN server set up so I had a configuration file in /etc/httpd/conf.d/ to set up subversion. All my SVN repositories are under the location /svn. Reading SVN repositories worked fine, but I kept getting “path not found” errors when committing new files. After debugging this for quite a while using Fiddler, and other means, I finally realized that Resin was actually handling the PUT http request and, finding no file, returned a 404.

So to fix this, and simply have Apache handle any request to /svn/ I modifed my httpd.conf file as follows:

then restarted Apache. Now apache handles any requests to /svn/* and Resin handles all other requests. Hopefully this helps future Googlers in need.

Filtering a CFGrid

| Comments

So you want to filter a CFGrid huh? ColdFusion makes this easy! First you need a CFC method that will return the query used to populate the grid. This method should take the cfgrid parameters and the value you want to filter on.

You can see here that I am just hard coding the query in, you would replace this with your cfquery call to your database or a call to your service layer, etc. Once you have your query results, you want to use the queryConvertForGrid function to format the result to a value that CFGrid can work with.

You then need a cfgrid! The trick here is how to get the grid to refresh as the user types a value in the filter box. ColdFusion Ajax UI tools have bind expressions that let us bind one control to another, and to react to events.

You can see my bind expression in the cf grid. It will call the getData method of my data.cfc and pass in the value from the “filter” input box whenever the key is released. ColdFusion provides other events you can react to as well, check the docs for details.

So now if you run index.cfm you will see a simple form with a text input and a grid. the grid will load when the page is run (bindonload="true") and as you type in the text box, the results are filtered.

EDIT: removed the example link as I have moved this blog to Railo

ValidatorCFC Update

| Comments

Just a quick note, thanks again to Aaron Greenlee I have some small modifications to ValidatorCFC.

The modifications allow you to return a struct where the key is the name of the field in your object, and the value is true/false indicating if it passed validation.

This is useful if you prefer more control when showing informative messages to the user.

The zip file is at RIAForge.

Adobe Releases Hotfix for FCKEditor Issue

| Comments

Adobe has released a hotfix for the FCKeditor issue. You can find it here. Take notice that it says to first stop the CF service and then access the CF administrator. This is impossible. Simple open the administrator first and apply the hot fix on the system info screen. Also, Mac (linux too??) users should know that if you unzip the cfide.zip file to the cfide folder it will replace the folder not merge the files like on windows. You will be left without a working CFIDE folder. You should manually merge the files.

Update to ValidatorCFC

| Comments

I released a new version of ValidatorCFC. Aaron Greenlee (http://www.aarongreenlee.com) sent me some changes. With his changes, you can now specify which properties you want validated. So even if in your object you say that last name and first name are required, if you pass in only the last name property, only that field will be validated. There is more info within the CFC itself, and in the test files in the zip. You can download the zip file from RIAForge.

Transfer Error When Using Ntext or Text and a ManyToMany Relationship

| Comments

When you set Transfer to use a table that has an ntext or text column on SQL Server 2000 (and perhaps later versions) and also a many to many relationship you may receive the following error when you attempt to retreive the collection for the many to many:

For example I have the following tables set up

And the following transfer configuration:

So when you call getRelationArray() on a Table1 object. You will receive the error. To correct this I took the following steps:

Create a for table 1 with the ntext column casted to varchar:

select id,title,cast(description as varchar(8000)) as description from table1

Save this as vwTable1.

Change your transfer config to point to the view instead of table one so


Now, you wont be able to run it yet because the view is not updatable since you used the casted field. To overcome this we are going to use an INSTEAD OF trigger.

You need to create 2 triggers. One will be called whenever UPDATE is called on the vwTable1 and the other will be called when INSERT INTO is called on vwTable1

You can create the triggers as follows, obviously change it to suit your table’s needs:

Once you have created these triggers you should be able to use Transfer as you normally would. Using the casted column in the view will allow you to call the getRelationArray(). The SQL that Transfer creates will no longer be invalid.

You may run into a couple of other items though. First, your ntext field is now limited to 8000 characters since you are casting it to varchar. You may be able to increase this, but I haven’t tried. Your mileage may vary, but be sure before the value is passed to transfer that it is validated as less than 8000 characters (perhaps in your decorator). Next, if you have any non-null, defaulted columns in your base table (a created date perhaps) you HAVE to provide a value when you call insert into vwTable1. Since Transfer is creating this SQL you have to ensure that Transfer includes that column. This means that you cannot use the ignore-insert="true" option in the transfer configuration. SQL Server will still respect your default value, as long as you provide that column in the sql statement pointed at the view.

You can find more information about INSTEAD OF INSERT and INSTEAD OF UPDATE triggers on the MSDN site.

I have only used this in a simple application with two base tables and one relationship table, so if your setup is more complex it may not work out for you.

Webservices Change in CF 8.0.1

| Comments

It seems with the change to 8.0.1 there is a difference in the way CF generates the stubs for a CFC called as a web service. I had a CFC called webservices.cfc and on 8.0 it was working fine calling the methods, but with the 8.0.1 it started throwing a “duplicate file name” error. This seems to be because CF creates its own stub file Webservices.java and also a [cfcname].java file. CF couldn’t create both so it threw an error. The solution was to rename my CFC. The stubs can be found in C:\ColdFusion8\stubs\ on Windows, and if I remember correctly /Applications/ColdFusion8/stubs/ on Mac OS X.