Sunday, April 11, 2010

ColdMVC: Create your own Helpers.

I wanted to try extending ColdMVC's helpers and create my own helper that formatted stuff for me and it turned out to be quite simple.

First, I created my own directory in my project called "helpers".

Second, I added a cfc named "format".

Third, I extended the ViewHelper from ColdMVC. Not sure, If this is the correct Helper Util class I am suppose to be using...but it worked.


<cfcomponent extends="coldmvc.utils.ViewHelper">

<!------>

<cffunction name="money" access="public" output="false" returntype="any">
<cfargument name="amount" required="false" default="0"/>

<cfreturn dollarFormat(arguments.amount)/>


</cffunction>

<!------>

</cfcomponent>


Lastly, I used my new helper function:

#$.format.money(product.getPrice())#


If you noticed in money() I set a default value of zero. For some odd reason when I put "product.getPrice()" in for the amount argument it has a value of [empty string] and it throws an error. The error says "The AMOUNT parameter to the money function is required but was not passed in.". But clearly there is a value of [empty string]. If any one knows what up give me hollar.

Entity Name is same for two CFCs

As I have been trying out CF9 and the ColdMVC I occasionally get this error "Entity Name Category is same for two CFCs". Where "Category" is my model cfc. This is ok if I really had two CFC's with the same name. Here's the rest of the error:

Entity Name Category is same for two CFCs, superior.app.model.Category and superior.app.model.Category.

As you can see, the error looks like it's pointing at the same file. Searching up and down my Eclipse project explorer I find no two cfc with the same name. Guess what...do a refresh on your model directory or where ever you put your VO's. You probably have two hibernate files, both containing your VO's name...mine was "Category".

Get rid of one of them and it should work.

Tuesday, April 6, 2010

Exploring ColdMVC

If you haven't checked out ColdMVC yet you should. It's a light weight ColdFusion ORM framework I've being playing around with. The biggest thing I was impressed with is the tags on the views you can make...I am easily satisfied.

Have you ever been tired of typing that same css container.
Ex:

<div class="buttons">
<!--- some buttons --->
</div>


With ColdMVC's tags that section turns into:

<buttons>
<!--- some buttons --->
</buttons>

The tags help keep the view clean. The only worry that I have NOT ran into yet is that helper tags are very similar to html tags. Not sure how it will play out yet, but no problems so far.