ColdFusion Quick Start Options

CFML or ColdFusion Markup Language is one of the most accessible programming languages for the web.  If you’re a brand new ColdFusion* developer you have several options for getting up and running with ColdFusion.

As a web developer the key thing you must have before you build production applications is the knowledge and background to set up a developer environment on your computer or laptop.

With ColdFusion there are several options available and I’ll cover the 3 main ones here:

  1. Adobe ColdFusion trial edition – this is the simplest way to start in my opinion and the approach I use most often.  Go to adobe.com/coldfusion and download the version for your operating system.
    • Adobe ColdFusion is a paid product so you should be aware of that if you go this route and hope to put your application into production.
    • Once you go production there are number of web hosting companies that offer ColdFusion hosting, but personally I like to spin up my own server with Amazon (AWS) and make use of the cloud-licensing that Adobe offers.
  2. Lucee – Another great option with the clear advantage of being open source and freely available.  Without getting into a lot of technical details this open source edition was previously called Railo.  For most intents and purposes anything you see that refers to Railo probably now refers to Lucee.  Check out the Downloads page on lucee.org for the latest release.
    • I probably should take back what I said about Adobe ColdFusion being the simplest path to ColdFusion development.  The Express edition of Lucee offers an even simpler way to get started and is only a 70MB download.  However, I’d recommend using the normal installer when setting up a production server.
    • There are going to be some differences between Lucee and Adobe ColdFusion.  For example in many cases Lucee may out-perform it’s very distant commercial cousin.  On the other hand there are some proprietary features in Adobe’s product that can be very compelling for certain use cases.
    • In most cases language differences should be minimal, but I would not normally expect a code base created on one engine to work on a different engine without at least some tweaking.
  3. CommandBox – Okay, this one isn’t a CFML-engine per se, but it is a quick way to get started with ColdFusion.  CommandBox is the leading ColdFusion-powered command-line environment and I’m a huge fan of this tool.  Download it from Ortus Solutions.
    • Under the hood this tool is running one of the two CFML engines mentioned above.
    • I’m not even scratching the surface of what this tool can do, but if you’d like to get started quickly just run CommandBox and type the command server start in your project directory.  This will fire up a CFML server on your localhost.
    • Since I can’t cover everything I’d like to jump right to my favorite bit, the REPL.  Once you launch CommandBox, type repl and press Enter.  This puts you into the ColdFusion REPL environment.  From here you can type ColdFusion statements and see their output in the console.
command-box

Hello, World! example in CommandBox

 

Whether a brand new developer or a seasoned programmer, ColdFusion has something for everyone and can be a great on-ramp to your web development journey.

The 3 options presented in this article are actually quite different in terms of purpose and capability, but all 3 can serve to help you try out one of the most simple and easy-to-learn programming languages in use today.

*Finally, I would like to acknowledge an important technical distinction about my use of the word “ColdFusion” in this post.  Technically ColdFusion refers to Adobe’s ColdFusion product; whereas Lucee is considered a “CFML Engine” and is not correctly referred to as ColdFusion.

Are you a new ColdFusion developer? If so, let me know in the comments how you set up your environment and what approach works best for you.

 

Advertisements
Posted in coldfusion, development | Leave a comment

Just Start Writing

Today – I’m doing something very different.  I’m writing this now and I’m going to post it in roughly 38 minutes from now.

No matter what.

I’m just hoping for complete sentences and semi-coherency.  I’d prefer about an A- in spelling (especially given auto-correct), and probably about a B- in grammar.  But overall there’s no rules.

no. rules.

See how few rules there are?!  0 of them.

The point is to write something new, original and post it online.  It’s an exercise for me, not something you should have to endure, but if I don’t actually post it for you to see the exercise won’t be effective.  However, no one will blame you for cutting out a little early.

Maybe this will encourage someone else to do the same and just START WRITING.

My plan is to take John Sonmez’s free blogging course at some point, but that might not be right away, so why wait?  Just got to do it!

Overall my biggest hindrance to blogging is that it’s simply not part of my daily or weekly routine.  I bought into the idea of just starting by writing some time ago, but never intentionally carved out time in my daily life to make it happen.  Currently the only time I have officially budgeted is every other Monday from 5:15-6:15PM.  Realistically I’ll probably get about 45 minutes of that time.  So that’s 1.5 hours a month for blogging.  (At that rate it’s going to take a while to get good).

Besides that I can probably get another 1 hour or so per week in, but that time’s less predictable and less guaranteed in my routine.  (That’s the 3rd time I’ve mentioned it, sounds like a blog post for sure)

Another hindrance to me is I like playing with my blog more than I like writing.  I’ve definitely spent hours researching and tweaking different tiny nuances of how the blog is setup and running.  But compared to the lack of CONTENT those issues are pretty much irrelevant.

So… finally I’m past all that.

Which is good because I only have 10 minutes left to write.

I’ve definitely enjoyed this exercise.  Hopefully I’ve gotten this self-awkwardness out of my system.   No more “Hi mom! Look! I’m doing the blog!” type posts after this.

Also, there’s a lot of things in my daily life that I’m committed to habit goals, routines, etc.  This is NOT one of them.  Maybe it will be some day.  But don’t expect a blog post tomorrow.  The earliest I am likely to write a new one is two Monday’s from now.

But maybe in the mean time I’ll start thinking about writing more.  Go sub-conscious – you can do it!!

Here’s some of the broad topics I think would be natural for me to write about:

  • Productivity
  • Goal Setting
  • ColdFusion web development
  • Command-Line tutorials
  • Freelancing
  • Hiring Freelancers

3 minutes!  Thanks for reading this far.  I can only imagine any future post will be better than this one, but it was a great experiment to get the ball rolling on what I hope becomes a life-long habit of sharing knowledge with others.

See you next time!  Don’t share this anywhere.    Please!  Sheesh… it’s gross and awkward!

Posted in meta | Leave a comment

JavaScript Undeclared

So how does one determine whether a variable has been declared in JavaScript? I’ve seen two possible methods:

1) Use the in operator:

var x;
alert("x" in this); // alerts: true
alert("y" in this); // alerts: false

2) Use the hasOwnProperty() method of an object:

var x;
alert(this.hasOwnProperty("x")); // alerts: true
alert(this.hasOwnProperty("y")); // alerts: false

What’s the difference between these two? The in operator follows the prototype chain to locate a property, hasOwnProperty() does not:

var o = {};
alert("toString" in o); //alerts: true
alert(o.hasOwnProperty("toString")); //alerts: false

One other small difference is that hasOwnProperty() seems to work on a primitive whereas in does not:

var s = ""; // create a string primitive
alert(s.hasOwnProperty("length")); // alerts: true
alert(s.hasOwnProperty("nope")); // alerts: false
alert("length" in s); // TypeError: invalid "in" operand s

Apparently this is because when you call a method on a primitive it’s temporarily converted to its related Object (e.g., “String”) and discarded afterwards. With the in operator there is no such conversion.

Note: If you’re following these examples, be aware that in IE9 I got “Object doesn’t support this property or method.” when trying to call this.hasOwnProperty() or window.hasOwnProperty() in global context. Any other object should not have this issue.

So while it’s interesting and maybe helpful to know if something has been declared, there’s a big difference between being “declared” and being “defined”. Stay tuned for details on testing whether or not a variable has been defined…

Finally, here’s a few links that were helpful in preparing this post:

Posted in development | Tagged | Leave a comment

JavaScript Thinking Global

The more time I spend working with JavaScript the more I’m continually surprised at it’s robustness as well as it’s many peculiarities.  In an effort not to re-think down the same paths again and again I thought it would be good to document some of my discoveries.  So this is the first in what I hope will be many JavaScript explorations.  Many will be highly academic (like this one), but will hopefully lead to better understanding of how the language works and can be put to very practical uses.

So to get the ball rolling… I’ve recently discovered that (in a browser host) the pre-defined window object and the unnamed global object are the same thing:

alert(this === window); // alerts: true

So global context code that sets values on this is at the same time setting the same value on the window object:

this.x = 1024;
alert(window.x); // alerts: 1024
alert(x); // alerts: 1024

As you can see in the above example, in addition to this (the global object) and window being the same thing, unqualified top-level variables are also scoped in the global object.

Another point to be made here is that window is actually a property on the global object that references the global object itself. Consider the following:

x = 1024;
alert(window.x); // alerts: 1024
alert(this.x); // alerts: 1024
alert(this.window.window.window.window.x); // alerts: 1024

So I thought I was understanding all of this until I attempted the following:

alert(this.window === window); // alerts: false in IE

I felt certain these would be the exact same object reference, but apparently not. Along the same lines I currently am not understanding the different behavior in these lines of code:

this.x; // no error
window.x; // no error
x; // ReferenceError: x is not defined

What is the difference between this.x being undefined (no error) and unqualified x being undefined? I plan to investigate and hopefully follow-up with a better explanation in a future posting. Any ideas out there?

Edit: The question about this.window not being strictly equal to window was somewhat addressed here: http://stackoverflow.com/questions/4180013/javascript-this-window-not-equal-to-window.  This turns out to be an Internet Explorer peculiarity.  In FireFox and Chrome this.window === window is true.

Edit: The question of the undeclared variable is given a little attention in this post: http://stackoverflow.com/questions/2543698/undefined-vs-window-undefined-in-javascript. Basically, x is a global var, it just happens that any global var can be accessed as though it were a property of window. Accessing an undefined property of an object returns the value of undefined, attempting to access an undeclared global variable generates an error.

Edit 6/20/11: I think a more accurate explanation for the behavior of x; versus this.x; is that when specifying the window or global (this) object we are terminating the identifier resolution process. Without the qualification the identifier resolution process continues until the scope chain is exhausted.

Posted in development | Tagged | Leave a comment

Restoring default Flex tree icons

I came across this gotcha recently when working on a Flex Tree component where I wanted to use custom icons. The Flex component has a attribute “iconFunction” that can be used to return a custom icon based on whatever logic you want. In my case, I was satisfied with the default closed and open folder icons that the component uses, but wanted to override the leaf node icons. I started with a Tree tag, such as:

<mx:Tree id="tr1" dataProvider="{model.xmlTreeData}" labelField="@label"
     iconFunction="getTreeIcon"
     click="handleTreeClick(event)" />

which uses a simple XML document to construct the tree. The XML tags that make up the leaf nodes of the tree all have a “department” attribute. I have an icon for most departments as well as a default. If you use “iconFunction” the Tree will expect the custom function to return something for both folders and leaves. The trick here was to reference the folderOpenIcon and folderClosedIcon that are styles on the Tree itself. Here’s my custom icon function:

private function getTreeIcon( item:Object ):Class
{
   if ( tr1.dataDescriptor.hasChildren(item) ) {
      if ( tr1.isItemOpen(item) ) {
         return tr1.getStyle("folderOpenIcon");
      }
      else {
         return tr1.getStyle("folderClosedIcon");
      }
   }
   else {
      var treeNode:XML = item as XML;
      var department:String = String(treeNode.attribute("department"));
      switch ( department ) {
         case "hr" :
            return icoHR16;

         case "shipping" :
            return icoShipping16;

         case "retail" :
            return icoShoppingCart16;

         case "accounting" :
            return icoCalc16;

         default :
            return icoDoc16;
      }
   }

   return icoDoc16; // should never be reached
}

This function first checks to see if the passed item has any children (that is, to see if it’s a folder) – if so, it returns the appropriate style either open or closed. Otherwise it assumes it is a leaf node and looks for a defined “department” icon.

I’m not sure if this is the best way to do this (mainly due to the heavy coupling between the icon function and the specific Tree instance), but it worked for me and thought it might be a common enough scenario that others might benefit from this example. If there’s a “right” way to do this, please let me know!

Posted in development | Tagged , | 2 Comments

ColdFusion tip: remove list duplicates

This is a quick ColdFusion snippet that will process a list and remove any duplicates so that only distinct elements remain.  srcList below is the list containing duplicates.  distinctList is the resultant list with duplicates removed.

<cfset distinctList = ""/>
<cfloop list="#srcList#" index="item">
    <cfif NOT ListFind(distinctList, item)>
        <cfset distinctList = distinctList & IIF(distinctList EQ "",DE(""),DE(",")) & item />
    </cfif>
</cfloop>

Hope this helps someone!

Posted in development | Tagged | 3 Comments

Java Time Zone Detection on Windows Vista

If you are running an older Sun JRE on Windows Vista there may be some issues with time zone detection, in which case Java defaults back to UTC. This was causing problems with my local copy of ColdFusion MX 7 Server and Eclipse 3.2.2.

ColdFusion: ColdFusion is distributed with an internal JRE that I updated to 1.4.2_14. This was not the most recent version available at the time, but I wanted to match my production web server. (BTW, if you need older versions of Java you you can download them here) I had better luck downloading and installing the SDK as opposed to the stand-alone JRE. With the SDK you still have to run the setup EXE, but you can choose to just install the developer tools and nothing else. Once it was installed I stopped ColdFusion and went into my CFusionMX7\runtime folder and backed up the existing jre directory. I then copied the jre directory from the SDK install into my ColdFusion runtime folder and restarted ColdFusion Server. This fixed my CF issue immediately.

Eclipse: In my case updating Eclipse was simliar to updating ColdFusion. Since I had the FlexBuilder 2 Plug-in installed, it had taken over as Eclipse’s internal JRE. Updating the jre installation underneath the FlexBuilder 2 Plug-in install directory fixed my Eclipse issue as well.

Posted in development | Tagged , , | Leave a comment