n42 Designs

Custom Web Development

Issue W/ Eclipse Resource Bundle Editor Plugin and Leopard

| Comments

There seems to be an issue with the Resource Bundle Editor Plugin for Eclipse.

I installed version 0.7.7 into a fresh install of the Eclipse 3.3 SDK and was unable to open a resource file. I would get the following error:

Can’t start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is not specified in your application’s Info.plist or on the command line

To fix it I edited the eclipse.ini file (/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini by default) to add the following line:

-Djava.awt.headless=true

Once I did that it was fine and I was able to edit the resource bundles.

Hope this helps someone searching for the issue!

ColdFusion ORM - Developing the Business Objects First

| Comments

Since I have transitioned from a world of spaghetti code through the land of the uber-cfc, and finally onto some OO concepts, I have tried to figure out what the best way to create the business objects and persist them to the database. For nearly ever application I have developed, I have created the database first, since, in my mind, understanding the data is the first step to understanding the way the application will function.

However, in the OO world, the primary step is to design the business objects. In my latest project I decided to take one step deeper into the OO world and develop all my business objects forgetting all about how the database would be laid out. I had no problems with this, authoring complex objects containing arrays or instances of other objects without issue.

Then I needed to figure out how to persist them. In the past, each of my business objects directly mapped to a table in my database. This made it easy to build a code generator, read in the DB metadata and, in the words of John Madden, “Boom”, I had my beans, DAOs, and Gateways.

Now, I see what Sean Corfield refers to as the “5:1 Syndrome”. I have a dumb bean object, a DAO, a Gateway, a Service and, if using Model-Glue, a Controller for nearly every object, and in turn every table in the database. This always seemed like code bloat to me, so I was very happy to see other, like Sean, refer to it as such. There must be a better way!

Trying to avoid this I decided, OK I’ll use Reactor. Active Record, generated code, sounds good. Then I realized that I have to create the database first. Back to square one.

Should business objects reflect the organization of the database? They can, but if it doesn’t fit the way the business object is used in the application, then no, it shouldn’t. Also, from the other way, the best way to organized the business objects is probably not the best way to organize the database. The database should be in 3NF, avoid duplication whereever possible, etc, etc.

Not wanting to trash all the BOs I created already, I decided I would write all the persistance stuff myself. So now that I have some beans, I created a service for each and wired them up in ColdSpring. I put all the methods that would normally go in my DAO (save, new, and CRUD) in my service as well as some getAll() calls.

As a side note, I don’t return query objects since, even though they are faster than creating an array of objects, I cant call a complex getter, such as a calculated value easily, and this allows me to use the same calls to get the data for one instance of an object as I do for a collection.

Now I have a BO and a service that is completely separate from the DB. Persisting complex objects is a bit more complicated than using the 1:1 BO to DB mapping, but it works. The only issue is, I don’t want to have to maintain all this manually. I wish we had a mapping tool to handle persistance from BO to DB without requiring that the DB reflect the BO or vice versa.

Java has Hibernate to handle this issue. With CF8 we can now use Hibernate with a Java model, but what if we want to model using CFCs? cfHibernate attempted to do this and seems to have run into some issues. Can we use Hibernate to map CF objects to the DB? I am going to attempt to find an answer for this in the next few weeks for my current project. Hopefully I can find a solution.

ColdFusion 8 Released!

| Comments

Just a quick note that CF8 has been released by Adobe. If you haven’t seen the new features, download a copy and see for yourself.

ValidatorCFC

| Comments

This component validates the data in an object according to custom rules you set up. It is especially created to determine data validity for a data store (DBMS, etc) rather than for business rules, but you can set up your own complex rules. Some may be out of its scope, however.

I just uploaded version 0.1.000. It is very much a work in progress and I welcome feedback.

Take a look and let me know what you think. You can find it at http://validatorCFC.riaforge.org.

Here is a rundown of an example usage:

Integrate a Model-Glue Application Into FarCry

| Comments

I’m sure there are other ways to do this but this is how I was able to integrate an existing Model-Glue application into a FarCry site. I am using ModelGlue 2.0, the latest ColdSpring BER as of this posting, and the latest beta of reactor.

My MG app in question is a events calendar. Its a pretty simple application using MG, Reactor, and ColdSpring.

Because I don’t want to use ColdFusion mappings (and its running on CF7 so no per application mappings) I copied modelglue, reactor, and coldspring into {farcry_root}/projects/{site_name}/www as www/modelglue, www/reactor, and www/coldspring.

If you are using mappings you can skip that step.

Next, I created a simple include file called _mgCal.cfm in {farcry_root}/projects/{site_name}/includedObj.

The code for this is as follows:

Now, in the FarCry webtop, under the site tab, navigate to the root node, and under utility, create a new navigation node called “Calendar” and under that, a new include called “Calendar”.

Publish both. The friendly URL should be /go/calendar, but it can be whatever you like.

Now we have to copy our MG application into the site tree. Create a new folder called mg under the www folder. This is where all my MG apps will live. So I copy my mgCal folder from my test site into the mg folder I just created giving me a directory structure like so:

1
2
3
4
5
6
7
8
/www/mg/mgCal/
/www/mg/mgCal/config
/www/mg/mgCal/controller
/www/mg/mgCal/model
/www/mg/mgCal/views
/www/mg/mgCal/Application.cfm
/www/mg/mgCal/index.cfm
etc

Now we have a few modifications to make to the MG app to get it to run from this location. Depending on how you first created the MG app, your settings may be different.

In your MG App’s index.cfm file add the following line above the <cfinclude> that calls Model-Glue.

Now MG can find your ColdSpring configuration file.

In your ColdSpring configuration file edit the following properties:

In your modelGlueConfiguration bean:

The paths should be straight forward, but your defaultTemplate property must be set to the FriendlyURL of your include.

In your reactorConfiguration bean:

You will want the paths to match those you set up in the previous steps.

Now for the tedious part. This was easy for me since I only have a few views, but a complex app with a large number of views will probably be a bit more work.

In each view that calls #viewState.getValue('myself')# you will have to, prior to any of those calls run the following statement:

This is to prevent a url like /go/calendar?event=some.mgEvent from happening. The friendlyURL is hiding some other FarCry URL variables. So there is already a ? in the URL. This will replace the ? that MG creates with an ampersand so you can attach the MG url variables easily.

Thats all it took to get my simple calendar MG app running under FarCry. A more complex app may need more to get running, but at least this will get you started.

If any one has any suggestions on a better way to handle this, I am all ears. I tried to find another instance of someone doing this in both the FarCry and Model-Glue lists to no avail.