Installing FarCry 3.0.2 Release Candidate

I had a few problems getting the FarCry 3.0.2 Release Candidate installed today so I thought I'd share what I did to get it up and running. I was trying to install from the farcry-milestone_3-0-2RC_r286.zip, available from the FarCry downloads page. I was following the installation guide, but I kept getting errors while running the installer. I decided to ignore the errors and see if I could view the site or login to the FarCry administrator. I couldn't. After a little digging I was able to determine that the installation files included in the zip expect to use the older pliant webskin, while the download includes the more recent mollio webskin. To get the installation to run I had to make changes to a couple of templates.

farcry_core/admin/install/index.cfm

  • Line 105: change farcry_pliant to farcry_mollio

farcry_core/admin/install/_createDefaultNodes.cfm

  • Line 15: change displayPageLanding to displayPageTypeA
  • Line 39: change displayPageLanding to displayPageTypeA

After making these changes I was able to run the installer and updates to get a working FarCry site. Note that I still got errors running the installer and updates, but everything seems to be installed correctly.

Calculating Image Dimensions

Yesterday I needed to get the dimensions of an uploaded image. I was just about to open up the Java API docs when I found this post over on Eddie Awad's Blog. So I know this is nothing new, but here is the method I wrote for my service. Note I'm passing in an ImageBean component and calling it's setWidth and setHeight methods once I have the dimensions.

<cffunction name="getDimensions" ... >
   <cfargument name="ImageBean" ... />

   <cfset var width = 0 />
   <cfset var height = 0 />
   <cfset var toolkit = "" />
   <cfset var image = "" />

   <cftry>
      <cfset toolkit = CreateObject("java","java.awt.Toolkit") />
      <cfset image = CreateObject("java","java.awt.Image") />
      <cfset image = toolkit.getDefaultToolkit().getImage(arguments.ImageBean.getFilePath()) />

      <cfset width = image.getWidth() />
      <cfset height = image.getHeight() />
      <cfset image.flush() />

      <cfcatch type="any">
         <cfset width = 0 />
         <cfset height = 0 />
      </cfcatch>         
   </cftry>

   <cfset arguments.ImageBean.setWidth(width) />
   <cfset arguments.ImageBean.setHeight(height) />
         
</cffunction>

Lighthouse Pro

I first gave Ray Camden's Lighthouse a try a few years ago when it was released on a DRK. I didn't end up using it at the time because I remember thinking that as my project grew the XML storage engine could become an issue. Since then I've used several commercial bug trackers including ProblemTracker and JIRA and currently my company is using a home grown issue/request tracking system.

Well, we recently started a fairly large project at work but I didn't want to use our in house issue tracking system as it generates several notifications and requires managers to route issues. While we will eventually move this project into our in house system, at this early stage of development it really didn't seem appropriate. So I decided to give Ray's Lighthouse another try, this time in the form of Lighthouse Pro. I have to say I'm really impressed. I downloaded the package and had the bug tracker up and running in less than 10 minutes. Best of all our team now has full control over our own bug database which should help speed up development and keep us from annoying everyone else in the company with all of our bugs. Not that we ever write any buggy code mind you.

URL/Database Safe Encryption

I was working on an application today where I needed to encrypt a query string. Using the encrypt() function alone would not work because it can generate non-URL friendly characters. There are the undocumented functions cfusion_encrypt() and cfusion_decrypt() that do just what I needed, but I didn't want to rely on any undocumented features in this application, so I did a little research. Turns out one way to go about this is to use tobase64().

Here is an example:

<!--- url/database safe encryption --->
<cfset myStringToEncrypt = "Encrypt Me"/>
<cfset urlSafeEncryptedString = ToBase64(Encrypt(myStringToEncrypt,12345))/>

<!--- decrypt url/database safe encryption --->
<cfset myDecryptedString = Decrypt(ToString(ToBinary(urlSafeEncryptedString)),12345)/>

I'll be using this method for any database/url safe encryption I need to do in the future.

The Value of Valid HTML

This morning I was working on the redesign of a small section of an existing application. What I found is that most of the HTML generated by this application was nowhere near valid. Now, when you generate invalid HTML you are basically leaving it up to the browser to decide how it is going to render the content. Some browsers give you what you want, others don't. This led me to do some quick tests of different browsers and what I discovered is that the HTML was so bad that some browsers (Netscape 4.8) crashed while trying to render it. (Older versions of Netscape were notorious for just not rendering invalid HTML tables, but I've never seen it flat out crash due to bad HTML.)

Anyway, as part of this redesign I've had to go in and cleanup some of the HTML. How did I do this? I validated the rendered HTML using the W3Cs validation services. It sounds like this could be a PITA, but browser plugins have made this extremely easy. I've been using the Web Developer extension for Firefox for a couple of years but recently MS caught up and release the DevToolBar for IE. (I still think the Firefox plugin is much better, but at least users of IE have something.) Both of these extensions offer validation for the page you are currently viewing. Because my dev server is not publicly available I choose the Validate Local HTML option. What this does is it saves a local copy of the HTML you are viewing and uploads it to the W3C Markup Validation Service.

I've found this process of validation invaluable as it often leads me to other problems in the code. (I discovered two additional bugs this morning. The first, incorrect img tag attributes, was the result of some bad CF code. The second, inconsistent rendering of the frame borders between browsers, was just a result of bad HTML.) Basically this validation process serves as another quality assurance procedure.

It's also worth noting that these tools also offer the ability to validate your CSS. This is another great way to help produce quality code.

SQL Prompt

A few weeks ago "Dave the disruptor" posted about a free sql tool on the CF-Talk list. The tool is SQL Prompt from Red Gate Software and what it does is provide Intellisense for SQL Server's Query Analyzer.

I don't use SQL Server for personal development, but I just started a new job last week where I'm working on a fairly large enterprise application based on SQL Server so I decided to give this product a try. So far this tool has been a huge time saver. Instead of searching in the object explorer to find or remember an exact table or column name I just type the first few letters and up it pops. Fantastic.

The only thing I didn't like about the product when I first started using it was that it requires a separate login to the database to get the database's info. Not a big deal if you are only working with one database, but if you have several databases that you switch between like I do, all of the logins can get kind of annoying. Well it turns out that if you look under the Connections tab in the SQL Prompt configuration tool there is an option to "Use same credentials for all databases on same server." Problem solved.

So I have to say that so far I really like SQL Prompt and would definitely recommend this product to anyone who is working on an unfamiliar database or who just hates typing.

ieHTTPHeaders

I'm a huge fan of the Live HTTP Headers plug-in for Firefox. It can be a lifesaver when it comes to debugging complicated redirects and cookie issues. Well today I was doing some debugging in IE and I wanted to see what headers were being passed to and from the server. A little looking and I found ieHTTPHeaders. The tool doesn't have all the features of Live HTTP Headers, but it lets you see request and response headers from a window in IE which is all I needed.

Underscore This

So today I ran into this strange issue while testing Oracle support for the next release of FarCry. I use the ACME environment for my local development (thanks to Stephen Collins!) so I had set up a virtual host named farcry_oracle.nmische.org in Apache for testing.

Does anybody see anything wrong with this?

Well, I didn't, at least not until I needed to look at something in IE. When I tried to login to the FarCry administrator I kept getting redirected to the login form. What was strange however was that I was able to login with Firefox just fine. In trying to figure this out I could see that IE was not setting the CFID and CFTOKEN cookies as expected. Now I have to admit, I probably haven't touched IE in at least two months, so my first thought was that it could be something simple like a security setting causing the issue. I went into IE's Internet Options and reset everything to the defaults. Still no luck. Next I resorted to looking at the HTTP headers to see if I could see anything strange. Everything looked fine there so I was really stumped. Upon further investigation I found a comment in the PHP documentation that finally lead me to the solution.

According to the RFCs domain names can only contain the letters (a-z, A-Z), digits (0-9), and the hyphen (-). Turns out the invalid underscore character in my subdomain was the problem. Firefox set the cookie for the invalid domain name just fine, but IE would not. Lesson learned, do not use underscores in domain names!

Java Libraries for PowerPoint Automation in ColdFusion

A client of mine recently asked me to take a look at a Java library they are planning to use for PowerPoint automation. I've done PowerPoint automation projects in CF in the past using COM, even thought Microsoft doesn't recommend it, but I had never heard of using Java for Office automation.

The library the my client is currently evaluating is called Aspose.Slides from Aspose Pty Ltd. Aspose seems to make an entire suite of products for Office automation for both Java and .Net which, depending on how well the Slides product works, may be a good thing to know.

However, it turns out that Aspose.Slides isn't the only commercial Java library for PowerPoint automation. A google search lead me to another company, Tonic Systems, which makes several products under the TonicPoint line for performing various PowerPoint related tasks via Java. They bill themselves as Java PowerPoint Specialists so this may be another library to keep in mind if you find you have to do PowerPoint work via ColdFusion.

I'll try to post more on both of these libraries if and when I get a chance to work with them.

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.