Best of CF9: PostIt

This post is more than 2 years old.

Today's Best of ColdFusion 9 entry comes to us from Corey Butler. It was reviewed by Brian Kotek. I'll be including his notes as well as mine intermingled below. Warning - the download for this entry is rather large. So instead of including it as an enclosure to the entry, I've instead FTPed it to my server. You can download it by clicking the URL below. The file size is a bit over 12 megs. (If folks have issue grabbing the code, let me know and I'll put it up on S3.)

Download URL: http://www.coldfusionjedi.com/downloads/postit.zip

Ok, so with that out of the way, what kind of application is PostIt? Corey was kind enough to provide a real nice installation document (both in Word and PDF). I'll quote from this document here:

This system, code named PostIt, is a new look on the old form management concept. It was designed as a form administration tool that developers could expand on. To accomplish this, forms are created in the Survey Manager interface and stored as XML templates. Developers leverage these XML templates to display forms in any fashion. These formats could be basic HTML, XML-compliant JavaScript Frameworks, or Flex to name a few.

I have some experience with survey builders (see Soundings) so I was rather intrigued to see how Corey approached it. I was also happy to see another content entry using an installer. Now, his installer failed pretty badly for both Brian and I (details below), but again - I think the fact the folks are at least thinking about installers is a great thing.

Following Corey's instructions, if you put the unzipped contents within your local qa folder, you will open your browser to http://localhost/qa/install. The installer asks for a DSN, but it doesn't actually create the DSN. As far as I can tell it simply takes the name and uses it to run an install script. However, there are two bugs here that both Brian and I found.

First, you will most likely get this error after you submit on the installer:

Argument 2 of function Replace cannot be an empty value.

The error occurred in C:\Apache\htdocs\qa\install\index.cfm: line 29

27 : <cffile action="read" file="#expandpath('./demo.template')#" variable="out"/> 28 : <cfscript> 29 : pth = replace(replace(CGI.PATH_INFO,listlast(CGI.PATH_INFO,"/"),''),"/install","","ALL"); 30 : str = replace(out,"{@URL}",CGI.SERVER_NAME&"/"&pth,'ONE'); 31 : str = replace(str,'//','/','ALL');

I got around this by removing line 29 and simply using:

pth = "/Library/WebServer/Documents/qa";

Obviously that isn't the optimal solution. Secondly - while the application asks for a DSN, it is hard coded to use "postit2". So I suggest simply using that.

The installer asks you for SMTP information. If you open up Application.cfc, you can see it makes good use of the new CF9 ability to set default mail settings:

this.smtpserversettings = { server=arguments.smtp.server, username=arguments.smtp.username, password=arguments.smtp.password };

A small thing - but I'm really happy they added this to ColdFusion 9.

Another thing the installer mentions, but again, it didn't work for me, was the ability to enable a Server CFC specifically for the application. I ended up added a access="remote" to his component and running it manually, but if you wanted to you could point to it in the CF Admin. I'm not sure what his installer was going to do with the checkbox, but maybe that will be enabled in the future.

After you get past the installer, the first thing you want to do is take a look at the Admin. The first thing you may notice is that you are running a HTML file - not ColdFusion. The admin is an Ext application that wraps calls to ColdFusion. Very slick! I thought it was broken at first when I couldn't get survey data to load. You need to double click on the survey! Once done, you get a pretty darn cool view:

I freaking love Ext-based applications. I haven't used Ext much, and I don't think it does things as well as jQuery, but for making application UI, it seems to kick some major butt. I also liked how the survey results included maps for respondents:

And check this out - here is how you edit matrix type questions:

The grayed out portion below is how the question renders. All in all - the admin is extremely well done and is giving me ideas on how to improve reporting in my own tool. Brian was also impressed by it as well.

On the negative side, Brian points out that the download size is way huge and could be trimmed quite a bit. While not the most important thing right now, it is something that folks should keep in mind when distributing software. Another issue is that the application will die if debugging is turned on. I see this quite a bit in applications. Don't forget you can always disable debugging by using the cfsetting tag. I try to do this in all my OS applications.

One big issue Brian points out is the use of a full system path when taking a survey. So for example, this is the URL you get when taking the demo survey:

http://localhost/qa/take.cfm?survey=/Library/WebServer/Documents/qa/data/general/demo.xml

That's a very, very bad idea. Even if take.cfm did security checks on the file it loads you should never be passing around full system paths like that. If we assume that all surveys must be under data, then the URL should probably look something like this:

http://localhost/qa/take.cfm?survey=general/demo.xml

Brian also points out that Corey makes use of CFM files to manually return JSON data. This is odd since ColdFusion can make JSON for you. Also, Brian points out (and I agree) that it would be better to hit a CFC and use CF's ability to auto translate results into JSON for Ajax calls.

Other random notes: It makes use of the VFS - which I swear is turning out to be probably the second coolest feature of CF9 (after ORM). It also makes use of the new caching system. Actually, I think between VFS, the new caching, and ORM, I'd consider those three to be the most important new features in CF9 (imho).

All in all - both of us think this is a very interesting start. It definitely needs some more work, but I'd love to see the next version of this!

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Scott posted on 12/19/2009 at 10:09 PM

Ray- having an issue downloading the postit code...Looks interesting though!

Comment 2 by Kumar posted on 12/19/2009 at 10:22 PM

Looks really good, time to try it out.

Ext styling really looks good on applications, it looks more polished and proffesional. You could stick with the default styles for an enterprise application if using Ext.

Comment 3 by Corey posted on 12/19/2009 at 11:32 PM

Thanks for the review, and I'm sorry for so many issues with the installer. Honestly, the biggest challenge with the installer was time. At the 11th hour, I realized there was a problem with the PGSQL dialect. I thought I covered everything, but I think I ended up opening up a can of worms instead of making many fixes.

A few clarity pointers. First, the download size is enormous because it includes the full ExtJS 3.0 library. Really, it would be best to download it from ExtJS, and this will actually be a requirement when PostIt is released (i.e. it will not be packaged with the download in order to adhere to ExtJS licensing terms).

As for the {@URL}... that should have been replaced by the installer. I use ANT to build most of my apps against shared resources & the installer was supposed to mimic the ANT build. Shame on me for missing that.

As for the surveys themselves, I also agree that a hard coded path isn't a best practice. The app determines the path by the setting in the config file. I personally set it to use a mapped folder, IF I even use take.cfm. The idea behind this is that take.cfm could be replaced by anything, ideally your own display page. Heck, it doesn't even have to be CF (though why would you want to use anything else? :) You just need to be able to read the XML.

In order to use the Server.cfc, you need to set the path in the CF Admin to point to the one included in PostIt. This is responsible for setting some hard coded latitude/longitude coordinates used in the survey reporting. Not everyone is going to want to change the Server.cfc path, so the checkbox in the installer will run the code for you (i.e. bypass Server.cfc). This is only useful for getting started... i.e. to see if you like the app enough to use it, then you'll want to use the Server.cfc method.

Finally, I agree that CFC's & their native ability to output JSON would be better. This app was originally written with ExtJS 2.0, which had some issues with CF's JSON output. There were situations where the JSON had to be manually constructed. It's since been fixed, but part of my choice in using this app was to show off that a CF8 app could be converted to a CF9 app.

Again, sorry for the installer issues. More testing/time should clear those up.

Comment 4 by Raymond Camden posted on 12/20/2009 at 12:06 AM

Corey, if you want to offer up a slimmer download, please do. You can post the URL here.

Comment 5 by Todd Sharp posted on 12/20/2009 at 1:21 AM

Why include/require ExtJS at all when it's already included in CF9 (including a full license - a $1200 value from what I understand). Couldn't you just point at /CFIDE for the scripts?

Comment 6 by Corey posted on 12/20/2009 at 3:54 AM

I've temporarily posted a slimmer version of the file at http://www.ecorgroup.com/po.... Including the docs, it's a little under 2MB. To use this, you'll need to download ExtJS 3.0 (extjs.com). You'll need to modify the JS path in the HTML file.

I have intentions of releasing this in some form on RIAForge at some point after I work out the installer issues. There were also a few things thrown in purely for demo purposes that I'd like to rework for practical use of the tool.

@Todd - I really wish I could. However; there are two flavors of ExtJS, the full version with the UI components and the core version that focuses almost entirely on data I/O. According to the docs, CF uses a customized version of the core. In a nutshell, Adobe took the core version and added a few basic JS classes from the full version, which is why things like cfmessagebox work. They also added a CSS theme... which is why the JS tools have that grey look. BTW - PostIt is completely skinnable.

Also, for everyone, ExtJS is kind of open source, regardless of version. Costs come into play when you release a commercial application or redistribute it commercially, and it's only relevant to the full version. However; I believe it's pretty reasonable... I think it's $275/developer for unlimited use. There is also an extra advantage to not using the version baked into CF... Google hosts ExtJS-Core on their CDN, along with JQuery & some other AJAX libraries. However; for simple apps that don't need a big GUI or just pieces, the CF version is going to be simpler to work with.

Comment 7 by Corey posted on 12/20/2009 at 3:59 AM

@Ray - I forgot to ask, did you happen to catch what kind of issues were cropping up with the debugging turned on? I didn't have any issues with that so didn't even think to check. Maybe you could PM me so I can address them.

Comment 8 by Raymond Camden posted on 12/20/2009 at 9:18 PM

@Corey: I didn't test w/ debugging on. When Brian said it was an issue, I just insured it was turned off.

Also - one small nit. Your code uses a include() udf. Don't forget CF9 supports include in script now. :)

Comment 9 by Marko Simic posted on 12/25/2009 at 6:48 PM

I really wanted to test this app, but had no luck.
I followed, with full attention (no slacking :)), installation instructions and tips provided by Ray and Brain, and still could not make it work. Maybe some issues with PostgreSQL (no MySQL installed)?

UI looks very nice. Survey maker is something that I would like to check out and see how it's working.

Corey, is it possible to set application online?

Comment 10 by Corey posted on 12/26/2009 at 7:54 AM

Marko - Can you provide some more detail around the issues? Any error messages?

The app was built & tested against PostgreSQL 8.3. It's possible there could be a DB version issue... you may want to try adding this.ormsettings.dialect='PostgreSQLDialect' to Application.cfc in the <cfscript> block at the top.

As for an online demo, I'll see what I can do. I know I won't have time until after things settle down from the holidays though. In the meantime, I'm happy to help troubleshoot if you can post a little more detail.

Comment 11 by Marko Simic posted on 12/31/2009 at 11:45 AM

Corey, Sorry for late response but end of the year is always bit chaotic.
However, I installed it again on my home PC and this time I succeeded :) Only difference was that I unpacked archive in "qa"

dir instead "postit/qa".

All I can say it was worth of installation hassle ;)
Application UI is excellent. I have no experience working with this type of software, but hence I created a survey in single

breath, I found it, from aspect of intuitiveness and usability quite a peace of work.

What I didn't like is code which, imho, is too "spaghetti"....and I like "spaghetti milanese" a lot :))

Happy New Year