Real World Flex/ColdFusion: Part 1

Word Count: 172

Today I am going to start a new series that I think anyone interested in Flex is really going to enjoy. I was assigned a task of building a new application at work about a month ago. Now that I have successfully deployed the application into testing I thought I would walk through the many things I learned from this project.

In part 1 we will take a look at the start of an application. What are the requirements, features and what are my recommendations as a developer. I also want to go through a little bit of the thought of why I have chosen Flex/CF for this project. After we take a look at what it is we need to build we will go through building our own version of this application. I have been doing Flex development here and there for a little while but his application really helped my growth and I hope it will do the same for you.

The application we are going to build is a document management system. The client needed a folder on a server that could act as a central repository for all kinds of documents. To start off with its just going to be PDF/Excel/Word etc.. but in reality we can allow for any type of document. Now that we know what we are building lets take a look at some features.

  • The ability to add / edit / remove folders & files. There will be one Root folder that will not be able to be edited, but from there the possibilities are endless.
  • Clicking on a folder will display the documents in a data grid to the right.
  • Speed is important and since the folder structure can be infinite we probably don't want to load thousands of folders at once. We will load just the documents that fall under our root and from there load the folders/files on a request basis.
  • The ability to move/copy files from one directory to another
  • Downloading files: If the user selects a single file will will allow them to download that single file. If more than 1 file is requested we will zip all of the files up and present the user with a zip download.
  • Uploader: The ability to easily upload multiple documents of any size and provide feedback to the user.
  • Themes - There are some really great themes out there for Flex now. The last thing we want to do is have an application that looks like everyone else!
  • *** Extra feature - down the line I think I would like to provide a way to flip from a datagrid to a thumbnail preview. This would become very handy if the user was storing images.

After I take a look at some basic requirements / features the wheels in my head start turning. To me this was a pretty easy decision to go with Flex/CF for this application. From the very nature of what Flex is, a rich Internet application. We want to provide the user with a slick / easy to user interface. While we could probably do this with Ajax I just don't think it would handle as well as Flex will. The drag and drop abilities alone were enough for me. On top of that we wanted to allow users to upload [x] number of documents at once. This to me is a great problem for Flex to solve. Not only can we allow multiple uploads but we can provide the user feedback as well.

The application that we are going to build together is going to be called RocketFM. The Rocket file manager is a demo application that will hopefully provide us all with a real world application example and the lessons learned from building it. Here is a quick mockup with some notes.

rocketfm

  1. The file system like folder structure. As we talked about before this is only going to load sub directories of the root folder and from there on it it will be on a request basis.
  2. The data grid will display the files of the selected folder. On entry of the application this will be the root directory.
  3. The status bar will tell us what folder we are in. Notice we are not showing the full path of the directory. Here we are replacing the Root directory with the label Home.
  4. The button placement is probably not a great design idea but this can change later. I thought about a toolbar up top but for these specific actions it just didn't look right.
  5. As we talked about before the download feature will be a smart download action. If the user selects one file they can just download a file. If they select more than 1 file it add all of the files to a zip file and present that for download.
  6. The upload button will open a new title window with our mutliuploader component.
  7. This is just kind of threw in at the last minute as something "extra". It may not even make our final application. I actually do this a lot during the planning phase. I think of required features and other little extra features that might add an extra touch. During the actual implementation process I will decide if a feature should make the build or not.

This application will by no means be model of how things should be done. Right now the final product works but I know there are better ways to do things and refactoring this application will come at some point. My intention is lend some knowledge (and I learned a lot from this) but at the same time learn from everyone out there. Please share your thoughts and any suggestion you have I will always listen to. With that said I will get to work on part 2 which should be coming very soon!

Comments

#1 Posted By: Aaron West Posted On: 1/2/09 2:56 PM
Dan, as I said on twitter I think this will be a good series! One suggestion and one question. First, the question: What did you use to mock up the app?

Suggestion: Do you have plans for how you're going to handle the multiple file downloads? More specifically, what are you going to do with the zip files you create after the user has downloaded them. In thinking about this I wonder if it might be a good idea to create a folder in Home named "Downloads." You could use a temporary server directory for the initial creation of the zip file and then move the file to Downloads just before sending it to the client for download.

If you added some sort of auto-description to each item in this folder - like a comma-delimited list of the zip contents - you could add further value to downloads. Why do I think this might be helpful? It'd only really be useful if someone needs to download something more than once and for tracking what things they downloaded and when.

If it's super easy to download multiple files and the process to do so is always the same (like selecting one folder and then pressing the download button) this whole idea may be moot. But if you plan on allowing the user to make download selections before performing the download I can see how this would make sense.

Thoughts?
#2 Posted By: Dan Vega Posted On: 1/2/09 3:08 PM |
Author Comment
First off the mockups are done using Balsamiq (http://www.balsamiq.com) and I actually have a review around here somewhere if you search for it. As far ad the downloads go here is how I did it. I have a temp folder underneath my source directory. When the user selects 1 file vs 10 files I call a method named download. I check the array length of selectedIndicies, if it is greater than 1 i do the zip else I just serve the file.

The great thing I learned while doing this feature is that cfcontent has a delete attribute. This makes it easy to serve the file to a user and delete it right after. Right now I am supplying the name but I am sure we can do something to allow the user to enter a name.

<cfcontent type="unknown" file="#arguments.name#" deletefile="true">

Hope this helps.
#3 Posted By: Dan Wilson Posted On: 1/2/09 3:46 PM
Nice! BigPipesVega on Real World Flex!

Your app looks pretty neat. I'm going to follow along the series. Thanks for putting this out there.


DW
#4 Posted By: Aaron West Posted On: 1/2/09 3:55 PM
Thanks for the link to Balsamiq Dan. I suppose the auto-delete feature of CFCONTENT is useful if you don't want zip files hanging around. But do you think there's any usefulness is hanging on to the zip files and reporting them to the user in case they want to redownload something?
#5 Posted By: Dan Vega Posted On: 1/2/09 4:05 PM |
Author Comment
If you can think of a use case for it I would love to hear it. In my case the user just needs to download a group of files. If they need to do the same download at a later date its not that hard.
#6 Posted By: charlie arehart Posted On: 1/3/09 8:36 PM
Hey Dan, yes, this does sound like a great series. Would you be interested in pulling it together into a talk for the online CF Meetup? (That's coldfusionmeetup.com, for those who've not heard of it.) I'm sure many would appreciate it and I would encourage you. Some folks lament "putting a talk together". It need not be that formal. With you now having done 3 parts, it would seem straightforward enough to make a talk out of it. :-) Needn't be anything really formal. If you may be interested (or anyone else reading this is), drop me a note at charlie at carehart.org. Keep up the good work.
#7 Posted By: Dan Vega Posted On: 1/3/09 8:37 PM |
Author Comment
@Charlie - I would love to do it. Let me get through all of these posts so I have and end game and we can set something up.
#8 Posted By: johans Posted On: 1/13/09 7:11 PM
Nice series Dan. Watch out with using cfcontent for file delivery, it uses a thread until the file transfer is complete. It does not take many users with large/slow file transfers, or refreshing download, to rapidly consume all the available threads and bring CF to a crawl.

I have found it far better to create temp transfer directories and a process that manages/deletes them. The web server then handles transfer and not CF. It also allows for client to reconnect and continue with transfer in event something goes wrong.


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.