Welcome to another (and almost the last!) entry in the Best of ColdFusion 9 contest. Today's entry is Collyba created by Marko Simic. It was reviewed by Francisco Paulino - Tofinha and includes his comments and mine. So what is Collyba? I'll quote directly from Marko's INSTALL.txt file:
This application is collaboration tool made for companies that frequently communicate (at this stage - chat) with their clients.Difference compared to IM is that this application (will) provide to its consumers ability to store, archive and search communication logs. On the other side clients, won't need anything else but link to their chat room (once it's done:)). Of course username and pass is mandatory. Once application is complete sessions will support video links (1:1) which, also, could be archived server-side. To make communcation richer, application will (or already does) provide many useful tools, like sharable Google Maps and file sharing.
Before getting into the bits, take a look at the screen shot of the chat UI:
And here is an example of the integrated map tool from the sender's side:
and here is what the other people in the room see:
And finally, a shot of the log interface (still a work in progress).
Ok, so what's behind this chat? Two very cool things that I'd love to see more ColdFusion developers make use of. First off - the chat data is sent back and forth using BlazeDS, part of ColdFusion 9. Secondly, and what I find most cool, is that this is an Ajax application. It makes use of Blaze via the Flex-Ajax bridge, which, if I understand right, allows Ajax applications to make use of Flash Remoting via a SWF embedded on the page. I don't think I've seen any tool like this out in the wild and I'm super happy to see a great example.
Also of note is that this is another example of an application using the FW/1 framework. I believe this is the third one so far which is really saying something for a brand new framework.
I'm surprised to see a mistake here that I've seen elsewhere - the use of the THIS scope within Application.cfc for Application variables. You can see these values copied in setupApplication. As I said, I've seen a few of these entries make the same mistake. Well, maybe it isn't a mistake per se, but it just feels wrong. In general, I think the THIS scope for Application.cfc should stick to what it was designed for - the application setup in terms of how it interacts with ColdFusion.
Also of note is how he seeds the data. Within Application.cfc he has:
if (arrayLen(application.companyService.getAll())==0){include"_addinitdata.cfm";
}
While this works, don't forget that ColdFusion 9 ORM also supports seeding databases. You can see an example of this here: ColdFusion-ORM: Auto-generation of tables, Naming Strategy and automatically populating data
All in all, a pretty darn cool application. Any comments? Note - the license file in the zip prohibits anyone from doing, well, anything. I spoke to the author and he updated the license to the text below:
Copyright (c) 2009 Marko Simic (marko.simic@gmail.com)
This software may be freely used, copied and distributed as long as it is not sold, and all original files are included, including this license
Archived Comments
First of all thank you Francisco and Ray for taking a time to review my code.
1. Application.cfc scoping. Honestly, since application.CFM got its CFC equivalent, I see it the same way way I see all other components. Of course, it is not, but still...
At the same time, I agree that we should use things what they are made for. Thinking of it, this is more inherited habit from latest client then expression of my attitude :)
2. CF9 as a whole, at the time I was working on this app was completely new to me. So, ORM was too. I am still digesting its basics (mostly via blogs and mailing list), therefore things like db seeding was too advance atm ;) Anyway, thank you for pointing to that feature.
Regarding licensing. I told you Ray that I suck with it. I never bothered with that in my life. So, if its content made you and anyone uncomfortable just for a second, I apologize. What so ever, I think I'll publish it as open source project, as soon as I finish basic feature set.
Don't be so hard on yourself re: license. They are difficult to grasp sometimes. It's something that 4CFF (http://4cff.org) hopes to help people with.
Marko: This is very, very cool.
Awesome stuff.
Hi Marko, I loved to finally see a AJAX-bridge demo for messaging.
I have a few questions:
1) why not create the custom endpoint the same way you create the dynamic destinations?
2) Any reason to create dynamic destinations instead of using subtopics?
3) Why not use setRemoteCredentials for authentication?
Once again, great job!
@Sam
Thank you
@Joao
First of all thank you for your blogs at www.onflexwithcf.org. In install.txt I promised I'll list everyone who helped me working on this, and sure you'll be on it.
1) At the time I was developing, BlazeDS, and messaging in general, was completely new to me. So, I get to idea of dynamic destinations when time was running out and had no time to develop that idea further...which includes custom endpoints.
2) I saved subtopic for private channels. Destination per client, subtopics per user.
3) See 1. Now, when you mentioned it, I'll read about it, and how it could fit in my solution.
Overall, I set myself fairly (if not too) high peaks to climb, in a relatively short period of time (3 weeks). Idea was too learn as much as possible on this project, and trust me, my brain want to blow in critical moments :)
Of course, any advice, hint or tip is welcome.
Wow that looks really awesome! The whole BlaseDZ things is totally fascinating! I'll definitely be checking that out. Marko, great job.
Thank you Ben!
@Marko,
My pleasure; now, I know I could Google this, but is there a good link you might provide that has info about the BlazeDS / flex-ajax bridge? I know nothing about it.
I'm gonna down load your project, but I just like the context as well.
One of motivation to go ajax-way was that is quite unexplored area. I spent many hours looking for example, but with no success. At the same time, I like to think that I am quite good in "looking for solution" :)
So, imho, your best friends areP:
a) Official docs http://livedocs.adobe.com/b...
b) Firebug & console.log(object)
c) /ext/js/chat.js from Collyba
It is totally legitimate, when you code Producers and Consumers, to think the same way you would do in Flex.
Communication components are:
- FDMSBridge.swf is a Flex app without UI.
- FABridge.js is Flex to Ajax bridge.
- FDMSLib.js is facade for mx.messaging.* methods
Communication flow:
You -> FDMSLib -> FABridge -> Flex(FDMSBridge) <-> Blazeds
At least that is how I understood whole this thing :)
Good luck and have fun.
Of course, If I can assist you on this any further, it would be my pleasure to help.
This is a terrific entry! Cheers on a fantastic job. You've definitely got me thinking about BlazeDS on CF9 and how to start using it. I wish this functionality was around years ago!
@Mike, BlazeDS first milestone release was available since Feb 14th 2008 (3.0 version) so this functionality is available for almost 2 years now.
Glad you like it, Mike!
While working on this, I was under strong impression that BlazeDS and LCDS are threated as a "privilege" of Flex developers. To be even more strange, BlazeDS is now coming preinstalled with ColdFusion 9, and I discovered it accidentally. As such it is a new feature compared to previous one, still I didn't see it anywhere listed.
Therefore, I don't wonder why Mike wasn't aware of its existence.
No matter what, I am quite sure it may play very interesting/important role in development of interactive CF/non-Flex applications.
anyone have any ideas why I may be getting the error:
java.sql.SQLException: Failed to create database '', see the next exception for details. (Application)
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
The request has exceeded the allowable time limit Tag: cfoutput
something about the variable base not found
I really want to see this work since I really want to see how the FW/1 framework works.
thanks
Dan
When you were creating a datasource in CF Admin, have you checked "create database", as described in install.txt? It is necessary before running application.
Yep I checked create database
I did not give it a database folder path nor did I change any advanced features.
I felt I followed the txt file instructions to the letter.
I am using CF9 download free edition from about 2 months ago...using the build in web server.
thanks for checking if I missed a step, but I am pretty sure I got all of them.
Dan
Ah, sorry to hear you still have a problem. I used exactly the same setup.For several times, I had a problem with db, but only on app init when CF was (re)creating db structure (DDL, based on persistent CFCs). However, single page refresh/reload was solving the thing.
On different mailing lists and blogs many devs are complaining on Derby DB. So, that may cause the problem to you too. Only reason why I used Derby is that it comes bundled with CF9. Honestly, I'll replace it with MySQL or PostgreSQL asap :)
Thinking of it. If you have installed any other db server on your machine, you can go with it. Just replace (or even totally remove) "dialect" value with correct one in ormsettings in application.cfc and you are good to go.
Checked the code and I called db directly only once, and that query is pretty much sql-92 compatible.
Thanks Marko
I'll look into this. One of the main reasons I'd like to get this working so I can see how you used FW/1...I am interested in it, and to see a working exmaple would be great.
I'll let ya know what I figure out.
Dan
PS -- I have not really checked much into ORM, so I may have issues with that, but I'll see what I can figure out about the system and why it is not creating the DB.
Congratulations application Marko. I think she has great potential.
Success!