Dan Mackey On ColdFusion Development

ColdFusion, Java, .NET, AJAX, DHTML development and general programming. Daniel is owner and Administrator of CFTagStore.com and works for an Application Development Company in Ireland called Digital Crew. His interests cover all areas of programming in multiple languages with a particular interest in Internet Technologies.

All Articles tagged : Flash
2009-08-09 22:10:00.0

Adobe AIR Flex 3 HTTP Basic Authentication

I am a week into Flex 3 development building an AIR app to test the new API for Teamwork Project Manager and thought I would share an issue with HTTP Basic Authentication that I ran into.

To be honest it has been itching away at me all day today and half of yesterday and I finally solved it.

What I am trying to do:

  • Connect to the Teamworkpm.net API
  • Pass my URL, Username and Password to be authenticated
  • Catch the HTTP Status code in the response
  • Catch any IO errors if the URL can't be found
  • Catch an authorization failure for the credentials passed.
  • Use the URLLoader class in Flex 3

Sounds easy doesn't it? Well, I got everything working fine and then hit a snag. If the credentials passed did not authenticate, then the ugly browser Login dialog appeared right in my beautiful AIR app. I tried everything and eventually even re-wrote the whole thing TWICE using 2 Google Code projects for AS3 HTTP Client calls.

How I did it

I decided to scrap it all and start again. This is how I got it working.

  1. I need to send the login credentials to the server but there was no native method to do this. You need to push an authorization header into the Request Header in base64
    • import mx.utils.Base64Encoder;
    • var loader:URLLoader = new URLLoader();
      var req:URLRequest = new URLRequest(cURL);
      var headerRequests:Array = new Array(1);
      req.method="get";

      var headerRequests:Array = new Array(1);
      var encoder64:Base64Encoder = new Base64Encoder();
      encoder64.encode(cUsername + ":" + cPassword);

      var credentials:String = encoder64.toString();
      headerRequests[0] = new URLRequestHeader("Authorization", "Basic " + credentials);
      req.requestHeaders = headerRequests;
  2. This solved the first issue and after running the app with valid credentials, everything worked fine. Now I needed to supress the ugly Dialog on invalid credentials.

    • You need to set the authenticate property of your request to false.

    • req.authenticate=false
  3. I need to get the status code back now and handle the exception thrown if the URL can not be loaded. This is very easy and all that's required is to add event handlers for the following events:

    • loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,onStatus);
      loader.addEventListener(Event.COMPLETE,onComplete);
      loader.addEventListener(IOErrorEvent.IO_ERROR,onError);

    • private function onStatus(event:HTTPStatusEvent):void {
      Alert.show(event.status.toString());
      }

      private function onComplete(event:Event):void {
      Alert.show(event.target.data);
      }

      private function onError(event:IOErrorEvent):void {
      Alert.show(event.text);
      }
    • Be aware that the event:HTTPStatusEvent is the first event handled and then the onComplete is handled.

I hope the above helps some people. Even though all I was missing was a simple property set, the Live Docs documentation was not very helpful and trying to figure out the way to accomplish the problem was difficult. I did manage to learn a heap loads of how the URLLoader, URLRequest and event handling works.

Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [9] - Leave a comment
2006-07-20 12:52:00.0

CF_ProFlashUpload Released on CFTagStore.com

Topper has released our Flash based Multiple File Upload with progress status for ColdFusion on CFTagStore.com

You can view the component and online demo from:
http://www.cftagstore.com/tags/flashmultipleupload.cfm

Pricing is $50 per application with discounts for multiple licenses.

Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [0] - Leave a comment
2006-06-23 12:03:00.0

ColdFusion Multiple File Upload On Mac OSX using Safari

Thanks Karl!!

Karl (a good friend and decent ColdFusioneer) took the trouble to test the Flash Upload widget on Mac OSX using Safari and it worked seamlessly!

We are getting close. Now all we need is Flash 8 to be released for Linux and we may have achieved our goal.

Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [0] - Leave a comment
2006-06-22 12:28:00.0

Flash Multiple File Upload Control - 90% finished!

As you all probably know, Topper and myself have been working on a powerful ColdFusion based multiple file upload control with progress indicators etc.

I am delighted to be able to post a link to a fully functional online sneak preview:

http://www.cftopper.com/playground/dcFileUpload/test.cfm

More can be read here on Toppers Blog

Just wondering if anybody with a Mac can run the demo and report back the results!

We have yet to get our hands on a Mac :-(

BTW, Linux still doesnt have Flash 8 released so the demo unfortunately wont run on Linux.

Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [2] - Leave a comment
2006-06-12 21:52:00.0

Thoughts On Flash, AJAX and ColdFusion

Peter and myself meet up regularly outside of work for a coffee and wild ramblings on the direction our development should be taking. We discuss upcoming technologies, applications that interest us aswell as arguing the finer points of whether Flash or AJAX should be used when creating online applications. What will happen to ColdFusion, etc etc

We had such a discussion today and debated the pros and cons of each. It went along these lines:

Flash

Flash is great but it is not wonderful in all ocassions. It has the potential to beat AJAX to a pulp but the sluggy controls make it painful to use. The sluggy controls I am talking about are things like Scrollbars, Buttons, Grids etc

Flash has also got a big enough learning curve if you come from a pure programming background and seems to be designed more for graphic designers than normal programmers. I know this is a brave statement but look at the Flash Development environment. You cant really start with a blank code page and work away. It is getting there though. BTW, the programming gone into the Flash IDE alone is superb!

Flash is perfect for things like Image manipulation and small widgets used in conjunction with HTML and Javascript. Its cross-platform and has a huge user base. Write once, deploy on different platforms with one code base.  Relatively secure code wise although unfortunately there are SWF decompilers available :-( The only true RIA Flash app I was impressed with was Yahoo Maps Beta

AJAX

Easy to learn and easy to use. The problem is all the different browsers and platforms need specific implementations. It cant access the local file system and cant do image manipulation particularly well. It is a good light weight tool for quick widgets where Flash would be overkill. I think Googles implementation of AJAX is the best out there. Gmail and Google Groups truely impress me. I often wondered about the pain involved in managing these apps with all the different browsers and platforms and code forks until I read about Google Widgets and realised they wrote everything in Java and their platform converted everything into AJAX enabled HTML code.

I suppose in a way ColdFusion is like that. Write in CFML and its interpretted/compiled into Java servlets. A good way to abstract things.

ColdFusion

We love it. But where is it going? Are Adobe going to ruin it? Was Macromedias decision to integrate it more with Flash the right direction to take it?

Will it eventually be stopped and integrated completely into Flex? I hope not.

ColdFusion is a great Application Server and has continued to stay ahead of BlueDragon. CFML is a great language and in my opinion the best choice for web applications. For pure and utter RAD development, ColdFusion is the way to go. If you need something extra you can call in Java using CFOBJECT or write a CFX tag in C++ or Java. I wouldnt pick any other language over it! We have used it for 6 years and recommend it everytime a new project comes in the door! The time saved building a project more than makes up for the license cost!

Forget Ruby On Rails and PHP etc but ASP.net is looking interesting. I kinda like the whole .net idea. Maybe CFML should be developed more as a language rather than trying to trying to put the kitchen sink into the Application Server. One thing that could be improved is its handling of data types... 

I noticed over the last 2 years Ben Forta has started to push Flex more in his blogs (as well as mobile technologies) more so than pure ColdFusion. I feel sad about that. Ben was the main evangalist of ColdFusion and it was nice to have someone like that presiding over the technology. I always found Ben very approachable via email and the few times I met him and liked to think of him as pure  ColdFusion but I realise what areas Adobe is pushing and hence Ben pushing them. I also found this sense of loss when Charlie Arehart left New Atlanta. Charlie was a great guy for helping the community and everytime we had an issue with BlueDragon he literaly got back to us straight-away and followed up until the issue was resolved. I think ColdFusion needs someone like that back in the community.

Which brings me to summing up what I have begun to notice in the last few years. The ColdFusion community is lacking support and resources.The community seems to be revolved around a small few people. EasyCFM used to be full of steam but has almost fallen off the radar. I wish I could help in some way. Maybe in the future I can.

The ColdFusion Exchange used to be HUGE back in the Allaire days but since being turned into a Rich Internet Application (pah..) its a joke. BTW, this is exactly the WRONG way to design an internet application. Sloooowwwww widgets and no right-click-open-in-new-window that piss people off!

Tags: AJAX | ColdFusion | Flash
Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [3] - Leave a comment
2006-05-29 13:25:00.0

Uploading multiple files with ColdFusion

One of the most common annoyances about ColdFusion is the way the file upload functionality is implemented. Unlike ASP, PHP, JSP etc, file uploading is not handled by the Application Server (ColdFusion) but is farmed out to the webserver (IIS or Apache etc)

This means that while the file is being uploaded, ColdFusion just kinda sits there waiting for the file to be uploaded and a reference to the file handed back to CF. This means that you cant use some of the upload tricks of ASP, PHP etc to show the progress of the upload etc

Over the years, Peter and myself have tried to find a way of accomplishing this on the server side but to no avail. We have tried CFX tags, Java servlets called through ColdFusion etc

Andrei Kondrashev made a good stab at it using a CFX Tag and ISAPI filter but if you are on a server where installing such beasts isnt feasible there is nothing much can be done.

We wrote an ActiveX and DHTML ColdFusion component to allow multiple file uploads but the disadvantage is that it is IE only for selecting multiple files all at once. The DHTML interface is cross-browser and will uploaded multiple files but still requires you to add each file seperatley.

With the introduction of Flash 8, the problem is now achievable. ColdFusion will still use the webserver to upload the file so server side analysis of the file upload progress is still a no-no but using a Flash Component, DHTML and some clever programming, we can select and upload multiple files and give user feedback on the file upload progress.

I am tasked with designing the interface, the methods required, functionality and documentation and Peter is going to do the actual Flash programming.

Together we are finally going to solve this annoying problem and will be releasing our solution on CFTagStore.com for others to purchase and use in their applications.

Using Flash is beneficial for the following reasons:

  • Client side checking of file size instead of waiting for a PFO from the server after the upload
  • Select multiple files using SHIFT/CTRL or drag a selection using mouse
  • Available to all browsers on all platforms
  • Interface with Javascript for customisation and control such as event handlers etc
Add to your del.icio.us    DIGG This!    Technorati Cosmos Link    Post to Reddit    Add to your Furl    Add to Blinklist
Comments [7] - Leave a comment