So you want to create a ModelGlue:Unity application? ( Part 1 )

In this series, we will create a ModelGlue:Unity application. Our example application will manage contacts. We will start with a blank canvas and by the end of the series, have a functional application.

Lets begin:

Firstly, you should have the ModelGlue:Unity and Coldspring framework installed. If the framework is not installed, have a look at this post.

Our application will reside in a directory just under the webroot. We will access our application at http://LocalHost/ContactManagerMG. With that in mind, lets open the ModelGlueApplicationTemplate Directory.

This directory serves as an application skeleton for which to begin a new ModelGlue:Unity application.

There are two ways to get a new application up quickly. The first way is to copy the contents of the ModelGlueApplicationTemplate into a new directory just under your webroot called ContactManagerMG. Do a find and replace on 'modelglueapplicationtemplate' and change it to 'ContactManagerMG'.

The second way assumes you have cfeclipse or some other ANT environment. The directions below are specifically for cfeclipse.

Inside the ModelGlueApplicationTemplate directory is a file called build.xml. Build.xml is an ANT script. ANT scripts are sets of commands used to perform file and directory tasks. There are certain parts of the ModelGlueApplicationTemplate that need to be changed to our application name ( ContactManagerMG ).

We will now make the modifications to the build.xml file for the purpose of creating our new application.

Open the build.xml file. On a default install of ModelGlue:Unity the file will look like so:

view plain print about
1<project name="New Model-Glue Application" default="build">
2    <property name="source" value="c:\inetpub\wwwroot\modelglue\modelglueapplicationtemplate"/>
3    <property name="target" value="c:\inetpub\wwwroot\"/>
4
5    <target name="build">
6        <copy todir="${target}">
7            <fileset dir="${source}" />
8        </copy>
9    
10         <replace
11     dir="${target}"
12     token="modelglueapplicationtemplate"
13     value=""
14     />

15    </target>
16</project>

In plain English, the build.xml file will copy the contents from the 'source' directory and place them into the 'target' directory then replace each instance of the 'token' and replace it with 'value'.

Make the following changes to the file and then run it.

IIS

view plain print about
1<project name="New Model-Glue Application" default="build">
2    <property name="source" value="C:\inetpub\wwwroot\modelglueapplicationtemplate"/>
3    <property name="target" value="C:\inetpub\wwwroot\ContactManagerMG"/>
4
5    <target name="build">
6        <copy todir="${target}">
7            <fileset dir="${source}" />
8        </copy>
9    
10         <replace
11     dir="${target}"
12     token="modelglueapplicationtemplate"
13     value="ContactManagerMG"
14     />

15    </target>
16</project>

Apache

view plain print about
1<project name="New Model-Glue Application" default="build">
2    <property name="source" value="C:\httpd\Apache2\htdocs\modelglueapplicationtemplate"/>
3    <property name="target" value="C:\httpd\Apache2\htdocs\ContactManagerMG"/>
4
5    <target name="build">
6        <copy todir="${target}">
7            <fileset dir="${source}" />
8        </copy>
9    
10         <replace
11     dir="${target}"
12     token="modelglueapplicationtemplate"
13     value="ContactManagerMG"
14     />

15    </target>
16</project>

Once your edits are complete, save the file and locate it in the navigator. Right click on the file and choose Run As -> ANT Build. You can see the progress in the console. Assuming no errors, you now have a new ModelGlue application and can begin coding.

Via Find and ReplaceANT build, you now have a new directory called ContactManagerMG. Run this in your browser and you should get a page showing the following:

Model-Glue 2.0: Unity

Model-Glue is up and running!

Voila. A new ModelGlue:Unity application. In the next series, we will add some functionality to our application.

So you want to install ModelGlue:Unity

ModelGlue:Unity is a ColdFusion framework that comes with a lot of of functionality and power right out of the box. In this tutorial, we will download all of the files needed to install ModelGlue:Unity, set up the framework and test our configuration.

ModelGlue:Unity requires the ModelGlue framework as well as the ColdSpring framework. We begin by downloading each part then placing them under our webroot.

You can find the latest builds in zip file format at of ModelGlue:Unity at http://svn.model-glue.com/trunk/modelgluebuilds. Select the most recent build and save it in a folder.

Update: Make sure the version of the ModelGlue:Unity framework is at LEAST version 284.

You will run into errors if you use an earlier version of the ModelGlue:Unity framework.

You can find version 284 here. A complete list of builds is here. Note the builds are sorted alphabetically so if you want the most recent, pay attention to the LAST decimal number. I.E. modelglue_2.0.284.zip is a later version then modelglue_2.0.52.zip even though it appears above in the list.

Next, download Coldspring 1.0 into the same directory.

Update: These instructions assume you will have both frameworks in webroot.

Placing frameworks in webroot is standard and preferred practice. If for some reason you MUST place the frameworks in a directory apart from webroot, you will need ColdFusion mappings for ModelGlue and for ColdSpring. There are few good reasons to install the frameworks in a directory other than webroot. If you have a good reason to do this, then you know who you are and what to do about it.

Now, unzip the contents of modelglue_2.0.xxx.zip underneath your webroot. When complete, you should have 4 directories direct children of your webroot.

  1. documentation
  2. modelglue
  3. modelglueapplicationtemplate
  4. modelgluesamples

Next, unzip the contents of the coldspring.zip file underneath your webroot. When complete you should have a directory called ColdSpring as a direct child of your webroot.

Verify the directories were created properly then run http://localhost/modelglueapplicationtemplate

If everything has been installed correctly, you will see:

Model-Glue 2.0: Unity

Model-Glue is up and running! Now Rejoice and tune in to the next tutorial.

Field is a reserved word in cfqueryparam

A workflow application I recently worked on tracks workflow between two groups, a legal group and a group working in the field. I aptly named the groups "legal" and "field".

This turned out to cause problems when using cfqueryparam. The column was a varchar column so I would imagine the text 'FIELD' would be just another string of text

Instead:

view plain print about
1Macromedia][SQLServer JDBC Driver]Unsupported data conversion.
2
3SELECT TOP 1 TimeCardID, ObjectID, UserID,
4UserType, DateTimeIn, DateTimeOut, DateCreated FROM
5TimeCard WHERE ObjectID = (param 1) AND UserType =
6(param 2) ORDER BY DateCreated
7
8
9(param 1) = [type='IN', class='java.lang.String',
10value='72FAE9F0-16D4-3001-353F84B2E749664D', sqltype='cf_sql_varchar']
11, (param 2) = [type='IN', class='java.lang.String', value='FIELD',
12sqltype='cf_sql_varchar']

I had no problem using the value 'FIELD' in the same column without cfqueryparam. It would seem something inside cfqueryparam must gets unhappy with the text string 'FIELD'

view plain print about
1SELECT TOP 1 TimeCardID, ObjectID, UserID,
2UserType, DateTimeIn, DateTimeOut, DateCreated FROM
3TimeCard WHERE ObjectID = (param 1) AND UserType =
4'FIELD' ORDER BY DateCreated
5
6
7(param 1) = [type='IN', class='java.lang.String',
8value='72FAE9F0-16D4-3001-353F84B2E749664D', sqltype='cf_sql_varchar']

Note: The word 'field' doesn't appear in the MSSQL Reserved word list nor in the SQL Reserved words checker by the illustrious Pete Freitag. Thusly, I believe this is specific to cfqueryparam only.

Flex Builder and CFMX RDS

Just a public service announcement for those using Flex Builder. Flex Builder really enjoyes defaulting to port 8500 at all possible turns. I was playing with the RDS extentions and couldn't get the server to connect. RDS was ( in fact ) enabled in the CFadmin. I changed the RDS password a few times and still had no connection. Turns out the default connection was to our friend port 8500. I found the configuration information in the helpful Flex Builder docs. The RDS configuration was tucked away in window/preferences. When creating a Flex project the docs say:

view plain print about
1To configure any ColdFusion servers that you want to connect to using RDS:
2In Flex Builder or Eclipse, select Window - Preferences - RDS Configuration.
3To configure the default localhost server, select localhost and specify the following:
4Description
5Host name (127.0.0.1)
6Port number (8500 if you are using the built-in web server)
7Context root, if necessary

Once the port was switched to port 80, I was in business. I want to do a full evaluation of the wizards available in Flex Builder. Dean Harmon has published three Adobe Connect sessions on Flex / CF wizards. I am going to give them a go and post my experiences later on this weekend.

Why I love Flex

Over the last 10 or so years, web based applications have used HTML. HTML describes the look and feel of the application to the web browser, a piece of software on your local computer. The web browser then interprets the description into a usable ( you hope ) application capable of interacting with users.

This process has worked extremely well, mostly for lack of viable alternatives.

[More]

AjaxCFC + JQuery

Rob Gonda has incorporated one of the top ajax libraries in AjaxCFC. For developers who appreciate the concise power of JQuery this is a big plus. If you haven't had a look at JQuery yet, this site is a great place to start.

I personally don't hate writing javascript, I just don't like the signal to noise ratio. It seems like I write many lines of code for a simple bit of functionality. The fine folks at JQuery have a tremendous amount of functionality in their library and in just a few lines, you can add some nice flair to your web applications.

So, a big thanks to Rob Gonda for pushing out the newest (alpha) release of AjaxCFC. We appreciate your efforts

The Ever Lovely Java 500 NULL error

While refactoring today, I got a dreaded Java 500 NULL error. This is by far my least favorite error because ColdFusion gives ABSOLUTELY no helpful information at all as to where the error occurred.

I am not sure why this error happens outside of the coldfusion error handler, you know, the one with the nice pretty information. Apparently it happens during a part of the process where coldfusion has no control, because coldfusion is usually tops on giving proper information onError.

After staring blankly at my screen for a few minutes, I tracked it down to the following section of code:

[More]

CFMX 6.1 versus CFMX 7: War of the Arrays

Arrays in 6.1 are passed differently than in CFMX 7. I know this to be true.

What does that mean?

There are at least two ways to pass the contents of a memory address. Let's look at each:

[More]

My Travels with Apache, Subversion and Windows XP Pro 64bit

A few days I completed an installation of Subversion on Windows XP Pro 64. Subversion usually a pretty easy set up. In this case I was setting up subversion on an XP Pro 64 bit OS and there was an annoying wrinkle to the process.

I didn't know much about 64 bit windows, just that it could supposedly run 32 bit applications with no problem. (You know backward compatibility and all that bollocks). At this point, I wasn't much worried about incompatibilities, seemed like a piece of cake.

[More]