How to Get Started With Flex

Due to a recent tweet of mine, I’ve received an influx of requests on how to get started with Flex. Here’s how to get started with Flex:

Go to the Flex Download Site to download the 60 day free trial version of Adobe Flex Builder 3.

Then to learn Flex, check out the following:

  • Flex In a Week is a free video training course that will help you get the most of your new Flex Builder software in just a few days.
  • Flex.org is an invaluable portal with links to all sorts of Flex information, know-how, learning, opportunities, and more.
  • Tour de Flex is a desktop application for exploring Flex capabilities and resources, including the core Flex components, Adobe AIR and data integration, as well as a variety of third-party components, effects, skins, and more.

Anyone else have good resources for learning Flex?

Flex Camp Miami

If you’re looking to get a leg up on your Flex knowledge, or see a preview of what’s coming in Flex 4, you should head to Flex Camp Miami on March 6th.

Flex Camp Miami
March 6th 8am – 5pm
BankUnited Center
University of Miami
Register

Flash Camp

Flash Camps are technical showcases for the Flash platform. At these events top speakers from both Adobe and the Flash Platform community show off both code samples and demos, to both help jump start new developers and inspire proficient developers with new areas to explore.

Getting Adobe Software For Higher Education

A couple of my educational customers have asked me this, and I figured I would come up with a canonical (for me at least) answer.

How do I get Adobe Software with educational pricing?

Free Software

Both ColdFusion and Flex Builder are free for Students, Faculty, or Staff using them for academic purposes. In order to take advantage of that, you have to go to either the Flex or ColdFusion FreeRIATools site. The only thing you have to do to secure the software is prove you are eligible. The easiest way to do so is to take a picture of your student ID and send it in. I know from experience that they accept that.

If you would like to obtain a bulk license for a lab or classroom, you can do it through that site. You just:

  • Accept the terms
  • Click the button for “Other”
  • Answer the questions about the lab
  • Select the number of licenses you want

Discounted Software

In North America, Adobe has a tool that will allow you to search for local resellers for our products. I did a spot check for the Philadelphia area (my local), and it looked very up to date.

Adobe – Find an education reseller

In Europe (and North America) Adobe products can be found online at Studica. Additionally Fuzzy Orange, can also resell Adobe software and provide educational discounts. They do not have a online catalog/store, but if you contact them they will be more than happy to help you out.

In other parts of the world, the online Adobe store has an educational section:

Adobe Store – Select a store

I’m not convinced this covers everyone so if you can’t find a way to buy Adobe products for Higher Education in your country or region, let me know, and I’ll research it.

Adobe Day – Washington DC

Adobe Days are free events designed to introduce you to various players on the Flash platform. Next week in DC we’ll be doing one focusing on Flex and ColdFusion.

I’ll be attending, lending moral support to Ryan Stewart. And by “lending moral support to” I mean “learning the ropes from”.

So if you’re in DC and are looking for a good and free overview of what Flex can do for you, c’mon down.

Adobe Day Washington, D.C.
Thursday, February 26, 2009
9:30 a.m. – 2:00 p.m. EST
Agenda

Grand Hyatt Hotel
1000 H St NW
Washington DC 20001

Registration is free.

Link: Adobe Day Washington DC

ColdFusion Has Many Roles to Play

Finishing up my series on my idea of why I am drawn to ColdFusion is my final point – ColdFusion has many roles to play. ColdFusion doesn’t force you to use only it for all layers of your web application. You can selectively choose to use ColdFusion for as much or as little of your application as you want. ColdFusion doesn’t just allow this, like everything else, it makes it easy. Off the top of my head here are some uses cases for ColdFusion in your application:

  • Traditional HTML generated application by ColdFusion
  • Complete client layer using built in ColdFusion AJAX components
  • Back end to AJAX driven front end using cfajaxproxy
  • Back end to Flex application using Flash Remoting or LiveCycle Data Services ES
  • Bridge between your application and messaging services (JMS, SMS, XMPP) with Event Gateways

Let’s start with the traditional HTML generated application:


SELECT *
FROM app.artists

Name City State
#firstName# #lastName# #city# #State#

Sure, I can just take a query and pass it to an HTML renderer and… instant data screen. ColdFusion can do the entire thing. But that code would provide a poor user experience. That table is pretty much just phoning it in. Instead, I can use ColdFusion’s built in AJAX features to make a better UI using a datagrid.

First I have to move the query to a CFC, and run it through a simple function that formats the data for the datagrid:

SELECT *
FROM app.artists

Once that is done, I can call that CFC from a datagrid component:

Or I can instead opt out of using ColdFusion UI components, and either roll my own or use an established framework (both using cfajaxproxy):

var cfData = new cfData();
cfData.setSyncMode();
cfData.setQueryFormat('column');

datatable = document.getElementById('dataTable');
res = cfData.list();
table = queryToTable(res);

datatable.appendChild(table);

function queryToTable(result){

table = document.createElement('table');
tbody = document.createElement('tbody');

for(i=0;i<res.ROWCOUNT;i++){
row = document.createElement('tr');

cellFname = document.createElement('td');
txtFname = document.createTextNode(res.DATA.FIRSTNAME[i]);
cellFname.appendChild(txtFname);
row.appendChild(cellFname);

cellLName = document.createElement('td');
txtLName = document.createTextNode(res.DATA.LASTNAME[i]);
cellLName.appendChild(txtLName);
row.appendChild(cellLName);

cellCity = document.createElement('td');
txtCity = document.createTextNode(res.DATA.CITY[i]);
cellCity.appendChild(txtCity);
row.appendChild(cellCity);

cellState = document.createElement('td');
txtState = document.createTextNode(res.DATA.STATE[i]);
cellState.appendChild(txtState);
row.appendChild(cellState);

tbody.appendChild(row);

}

table.appendChild(tbody);
return table;
}

If, however, I wanted to go with something other than HTML/JavaScript for the front end, I still have options. ColdFusion is perfectly suited to act as a back end for Flex. In fact that CFC above still works with Flex. To call it from Flex I just have to point an end point to it and add a datagrid:

But let’s say that you instead wanted to interact with some sort of other interface like SMS, JMS, or as in the following example, an XMPP client using Gtalk:

That’s a lot of mileage out of that little query. From that simple query, I’ve rendered a plain old HTML page, a ColdFusion AJAX display page, a custom written AJAX-driven page, a Flex display component, and a Gtalk Bot. That’s what I mean by ColdFusion can play lots of roles. It can do the whole thing, or just part of it. Combine that with the concepts in my previous post, and ColdFusion can do the following:

  • Act as a front end to business logic written in Java or .Net
  • Act as a back end to a front end written in Flex or HTML/Javascript
  • Act as a messenger from a back end written in Flex or Java to a front end written in Flex
  • Act as a messenger between all of these and a messaging service
  • And of course, it can be your front end, back end, and messenger all in one

The idea here is that when you use ColdFusion, you can either use it full hog, or selectively swap in technologies that better address your needs. ColdFusion doesn’t lock you in; quite the opposite, it opens doors for you.

ColdFusion Plays Well With Others

Continuing on with the series I started on Tuesday, I’m going to explore ColdFusion’s ability to play with many other technologies, and do so very well.

First, let’s start with what ColdFusion was designed for, getting information out of databases. ColdFusion ships with drivers for talking seamlessly to the following database systems:

  • Apache Derby    
  • MS Access    
  • MS SQL Server    
  • MySQL     
  • PostgreSQL     
  • DB2
  • Informix Dynamic Server    
  • Oracle
  • Sybase

Does that mean if you are a FoxPro or SQLite developer, you’re out of luck? Hardly – if it has a JDBC driver you can talk to it with ColdFusion.

Databases are only a portion of what you have to deal with, especially if you are talking to back end systems with various interfaces. The can include directory servers, file servers, mail servers, etc. Here’s a non exhaustive list of ColdFusion tags that can talk to those sorts of servers:

cffile, cfdirectory 

Both local and remote file stores 

cfexchangecalendar, cfexchangemail, cfexchangeconnection, cfexchangetask, cfexchangecontact, cfexchangefilter

Microsoft Exchange Servers 

cfftp  

FTP and SFTP servers 

cfhttp 

Other web servers, REST webservices 

cfldap  

LDAP Directory services, Active Directory 

cfmail, cfmailpart, cfmailparam 

SMTP servers for sending mail

cfobject, cfinvoke

SOAP webservices 

cfntauthenticate 

Active Directory for authentication purposes 

cfpop 

POP3 Mail servers for acting as a mail client 

cfprint 

Any printer accessible by the ColdFusion host 

 

That’s a pretty big list. Keep in mind that it’s not just about talking to those services; it’s about easily talking to those services. Yesterday, I showed the cfexchange tags and cfmail tags in action. They’re all pretty much that easy and concise to use.

Next, ColdFusion can call just about anything that can be run from the command line via cfexcecute:

#results#

That’s not necessarily compelling. Pretty much every programming tool can make calls to the shell. But I think it’s important to point it out, keeping in mind that this is a must have feature for any tool.

But shelling out to the OS, running a command, reading it into a variable and parsing it is a pain. It’s a lot of extra coding, extra bug trapping, and usually a performance hit. So it would be nice if you could interface with certain other tools without having to do that.

I kinda, gave a sneak preview of some of this content the other day, when I showed getting information from .Net into Java in two lines of code:

I didn’t have to import any libraries to accomplish this, it just worked from the moment I installed ColdFusion. I consumed a .Net assembly, got a string from it, and passed it a Java Object. That was just a string, but if the return had been a more complex object, ColdFusion would have converted it to a native ColdFusion structure. Any errors would have been caught and delivered via ColdFusion’s error handling mechanism. The same applies to the Java call.

The .Net communication was added in ColdFusion 8, but the Java communication has been around since ColdFusion MX 6. The reason behind this is the often overlooked fact that ColdFusion is written in Java, runs on Java, and can be looked at as Java framework. Anything Java can do, you can get done in a ColdFusion page or component. You might have to drop down to coding in Java to do it, but that’s pretty easy to do:

#result#

As you can see, I can use the result generated by Java without any special conversion.

Finally, ColdFusion can run with support from Adobe on many platforms:

  • Windows
    • Windows XP
    • Windows Vista
    • Windows 2000
    • Windows 2003
    • Windows 2008
  • Mac
    • OS X 10.4, 10.5
  • Linux
    • Red Hat 3.0, 4.0, 5.0
    • SUSE 9, 10
  • Solaris
    • Solaris 9, 10
  • AIX
    • AIX 5L, 5.2, 5.3

Those are just the supported platforms. It’s also quite possible to run CF on Ubuntu or Centos. (But I must stress, Adobe doesn’t support these distros of Linux, yet.)

I hope, I was able to show you in this long, but frankly shallow overview, that ColdFusion can talk to a lot of different system, using many different interfaces, and do so on pretty much every mainstream platform you could need.

DMD Project at Carnegie Mellon University

I got to see a very cool use for Flex and AIR in Higher Education today. It’s the DMD Project from the Masters in Human-Computer Interaction Program at Carnegie Mellon University.

It’s a prototype RIA for patient management at dental offices. It was designed for touch screens, but also can be used with the traditional keyboard and mouse interface as well. It shows everything dentists, hygienists, and front office staff would need to manage the entire patient interaction.

I got a chance to talk with one of the developers, Jaanus Kase, about it. He told me that they spent most of their time upfront researching how exactly dentist’s offices would need to interact with a system. That yielded a few custom interfaces, including the “radiograph view” which the rest of us just know as “an x-ray of all of your teeth.” The other cool thing I noticed was the high emphasis they place on important information like “Severe Penicillin Allergy.” Clearly, this program really does focus on quality computer-human interactions.

The project itself is a prototype; don’t expect to see it in your dentist’s office anytime soon. But the app is available as an AIR application for your review.

Jaanus is done with the Masters program now, and is working with an startup in New York named World Evolved.

Queries are the Secret Sauce of ColdFusion

Kevin Hoyt commented on my blog post yesterday about ColdFusion Makes Hard Things Easy. He reminded me of a feature of ColdFusion that gets overlooked because it is so elemental to the language: the query variable.

In ColdFusion results that are returned from database get returned in a query variable. Query variables are an implementation of the iterator pattern and have a few special properties:

  • Queries map columns from the database into easily addressable properties
  • Queries also have the obvious properties named recordCount, currentRow, and columnList
  • Queries have hooks to that cfloop and cfoutput can iterate over them
  • Properties of queries can be addressed easily within an iterating process

That’s all a really complicated way of describing what happens in this code:


SELECT firstName, lastname
FROM app.artists

#qry.recordCount# records returned with columns named: #qry.columnList#

#currentRow# of #recordcount# - #FirstName# #lastName#

You see, the first cfoutput tag didn’t have a query attribute, so I had to prepend the properties recordCount and columnList with qry. Later when I was iterating over the query using cfoutput, I didn’t have to bother prepending.

That’s cool, and easy, but not outside the realm of what you can do in other languages. So let’s get to what Kevin mentioned in his comment Query of Queries. Query of Queries refers to ColdFusion’s ability to use a ColdFusion query as a table against which to perform SQL in another query. Want to get all of the records from the previous query that begins with A:


SELECT firstName, lastname
FROM qry
WHERE firstname like 'A%'

Want to get all of the records that begin with E:


SELECT firstName, lastname
FROM qry
WHERE firstname like 'E%'

Want to combine the A records and E records:


SELECT firstName, lastname
FROM anames
UNION
SELECT firstName, lastname
FROM enames

That’s right query of queries will let you do unions or joins too.

Now some of you might be questioning the usefulness of this. You think things like filtering, joins and unions are operations best handled by the database. You’re right they do. But, imagine that I was pulling data out of separate databases, perhaps one in Oracle, and one in MSSQL? You couldn’t do it in the database.

Also cfquery is not the only tag in ColdFusion that creates query variables. The others include (But I’m sure I’m missing some):

  • cfdbinfo
  • cfdirectory
  • cffeed
  • cfexchange tags
  • cfldap
  • cfsearch
  • cfstoredproc

That means you can take any of the results of these tags and filter and group and join them just the way you can with a database. Want to see all of the files in your directory and are not .cfm files:

SELECT *, directory + '/' + name as fullpath
FROM files
WHERE name not like '%.cfm'

#fullpath# #size# #datelastmodified#

That’s pretty easy, and I think that qualifies as something not every solution can do. It opens up the door to a lot of other possibilities:

  • Joining LDAP data to SQL Data
  • Creating a union of multiple RSS feeds
  • Joining data about stored files to SQL data
  • Joining RSS feed data to Exchange users

ColdFusion queries, and query of queries are powerful features that make one of the most common jobs in web programming – displaying some kind of retrieved record – shockingly simple. Add to it that the number of entities addressable in a ColdFusion query includes many other sources than just the database, and you have one powerful feature that is not easily matched.

ColdFusion Makes Hard Things Very Easy

This is not the first time I’ve made the claim that ColdFusion makes things easy. This has been my chief reason for loving ColdFusion from day one. I’m going to take a few tasks, and show you how easy ColdFusion makes them.

Get some data out of a database and display it on a page:


SELECT firstName, lastname
FROM app.artists

#FirstName# #lastName#

Querying from a database using CFQuery just feels natural and easy. I personally hate saving SQL to a string, then attaching it to query object that I then execute. Looping over the results of query is also simple and straightforward. I don’t have to worry about addressing the query in a collection or other structure, CFoutput handles looping over the results and pointing my call of “firstname” to the firstname column in the current row of the results.

Send a short email to someone:


This is a test message

Similar to the database query, sending mail from ColdFusion is just drop dead simple. More than that, it’s pretty intuitive. It’s hard to not understand what is going on here.

These are pretty standard, and most tools have patterns written for them to make this sort of basic functionality easy to write. So let’s take on some harder tasks.

Create a PDF from some content:

Hello World

I contend that printing a document to the PDF Print driver takes more effort than doing it in ColdFusion. Feel free to disagree.

Create an image for use in CAPTCHA testing:


Notwithstanding everyone’s hatred for CAPTCHA, that’s shockingly easy to create a CAPTCHA image.

Okay, again nothing we did was too crazy but you have to admit that is some really easy, concise, easy to comprehend code. Let’s do something a little harder.

Pull all appointments named “Lunch” from your Exchange Server:

I’ve said it before, the only way of working with Exchange that is easier than ColdFusion is Outlook.

Pass a result generated from .Net to a Java string for use by a custom Java Library:

Interoperability between .Net and Java, in two lines of code? That’s kinda ridiculous.

Now, to be clear here, I’m not saying you can’t do all of this in other languages, I’m saying this is the easiest I’ve ever seen it done. The team behind ColdFusion has done a great job of balancing between encapsulating the difficult, but making it easy to go beyond what they enabled. All of the tags used in the examples have many more attributes that you can use to fine to the behavior show off here.

This was a overview of how easy ColdFusion makes it to do hard things, in the next series post I will talk more about what you can do with ColdFusion when ColdFusion can’t do what you want it to do. (That’s not a typo.)