Framework One Sample Application - QBall

I’ve blogged about Framework One (FW/1) a few times before. The more I look at it, the more I grow to like it and appreciate it’s way of doing things. I don’t prefer it over Model-Glue, but I think it’s got a lot going for it, and I think it will appeal to people who may not like Model-Glue. One of the biggest differences between FW/1 and Model-Glue is that almost everything you do in FW/1 is implicit in nature. There is no XML. There is no set of declarations for each event. Instead, the framework will do almost everything for you and save you from writing a lot of code that - for the most part - isn’t strictly necessary. This post isn’t meant to teach you FW/1 - see the docs for that. Rather I thought I’d share my experiences (and code!) for my first “real” application. Before I go any further though - please keep in mind: This is my FIRST FW/1 application. Do you remember your first ColdFusion application? Yeah - this is worse. I’m sure Sean and others who have used FW/1 will be able to tear this apart. That being said - I enjoyed writing this, and I enjoyed using the framework. I hope this sample is useful to others in some way.

So what did I build? My application is called QBall. It’s based on the recent rise of “Question/Answer” sites like Stack Overflow. Basic functionality includes:

  • User registration and login. Later on I plan on adding the ability to let you edit your information and see the content you have contributed.
  • Users can write questions. Questions are open ended blocks of text on any topic. Later on I'd like to add some basic tagging.
  • Users can write answers to questions.
  • Users can vote up and vote down answers to show their support.
  • The user who wrote the question can select an answer as the one they accept as best. </ul>

    So as you can see, there really isn't a lot going on here. The home page shows the most recent questions along with their current status:

    Here is a screen shot of a new question:

    And finally a shot of a question with a few answers:

    To use this application you will need the FW/1 framework (of course) which is all of one file. You will also need ColdFusion 9. I made use of script-based CFCs and ORM for all my data entry. Create a virgin database and setup a DSN called "qball" before running the application. After you've done that, it should "just work". If it doesn't, let me know. Actually - one thing that may not work for you is the mapping. I believe the docs typically show an "org" mapping for the FW/1 code. I created a mapping called fw1 instead. Whichever you chose, make note of it in line one in the Application.cfc file:

    component extends="fw1.framework" {

    Most likely you will need to tweak that.

    Ok, so what did I like - and what caused me a bit of trouble? Well for the most part, the thing that took me the longest to wrap my head around was the start/end cycle of controller calls. When you run x.y, FW/1 will look for an execute a startY method in your x controller, then the Y method, then the Y method of the X service, and finally endY back in the X controller. Having just looked over what I wrote I don't think that makes much sense (again, check the docs). That's somewhat different than what I'm used too and it took a little bit to get used to the "flow". Once I did though I didn't have much trouble putting it to use. Another thing that was a bit difficult was handling cases where the implicit actions done by FW/1 weren't exactly what I want.

    Anyway - download it and check it out.

    Edited February 28, 7:37 AM: Please note that QBall requires ColdSpring to be installed. I've updated the code to not use x.y.z in the entity relationships. Thanks to Andreas for that. I also fixed the dbdefault for answer.cfc (and again, thank you Andreas).

    Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless 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

Comments