Friday, November 13, 2009

How to call a controller in FW/1

Sean Corfiled wrote a simple MVC framework a few months ago called FW/1 (check it out here). I have been following the discussion list since the beginning. Last night I finally gave it a try. I was very impressed by it's simplicity. There isn't alot of documentation but there doesn't need to be a whole lot because it is so easy and Convention based. I had a view up and running based on the getting started doc in just a few minutes. Very nice. It is not only easy, understanding the conventions will surely help my development in model-glue and other frameworks, even when I don't use a framework this will help with my mental and code organization.

Then I moved to controllers. I just couldn't grasp how they were called. I reread the docs a few times and finally went to bed a defeated man. This morning I reread once more and it clicked, and the docs explain it perfectly, I was just a little thrown by the verbage, which I shouldn't have been. In model glue I call an event like so:

<event-handler name="maint.city">
<broadcasts>
<message name="needCity"/>
</broadcasts>
<results />
<views>
<include name="body" template="maint/city.cfm" />
</views>
</event-handler>

In FW/1 your url would be http://www.whatever.com/myapp/index.cfm?action=maint.city

FW/1 automatically calls the city() function in the controllers/maint.cfc controller. It seems almost silly that I couldn't figure this out, but It did escape me for a minute. I knew to create a controller and where to put it, but I wasn't sure how to call different functions etc.. In model-glue I would broadcast different messages. So I was thinking maybe I needed to call functions from my view or something, like city = rc.controller.getCityById().

Turns out, as mentioned that FW/1 calls the city() function automatically and i can call other stuff from inside that function.

Wednesday, November 11, 2009

Posting Code Snippets in blogger

I have always wanted a good way to post code snippets on this blog. My favorite is the way that Ben Nadel does it at his blog: http://www.bennadel.com/. I sent him a message asking him how he does this, but I have not heard back from him. I found a way to post code snippets but it ain't that pretty.

You use blockquote and the returned output from this parser: http://www.blogcrowds.com/resources/parse_html.php
ColdFusion Report Builder has Report Functions

I stumbled on a discussion at: http://www.justskins.com/forum/archive/index.php?t-5171.html that made me realize that Report Functions are available in ColdFusion Report Builder. I had been struggling with the expression builder using iif to conditional show fields. iif is a bear, you have to use DE(" ") and different things and it can be ugly.

As mentioned in the article, you cant use cfml syntax in the expression builder. But you can using report functions. This is a very nice feature. Since I get mad at adobe for that bad things better get happy for the good things. Nice one Adobe!
Coldfusion Report Builder Frustration

In my detail band I want to eliminate the blank lines when a field has no value. I my situation I return a lot # and subdivision and often times there isn't any listed so the line is blank. I don't want a blank line to show up. In Crystal Reports they let you add sections and you can choose to not print the whole section if it is blank anyway.

Coldfusion report builder has an option "Remove Line When Blank" but it flat out does not work for me. Nothing is removed. Whatever the secret combination of options is to make this work, I can't figure it out. C'mon Adobe, we really need this tool, please upgrade and fix it.