As I work my way through rebuilding CFLib (and yes, I still plan on deploying it live so people can see the progress) I ran into a few issues that I needed help. I'll make the assumption that my questions aren't stupid and share them here...
- Inside a controller I want to make an instance of a CFC. No big deal, but I needed the full path to the CFC. This was: cflib2005.model.library. As you can probably guess though, "cflib2005" was the root mapping for my site. I didn't want to hard code that in. Turns out you have a few options. The first is to simply use the <setting> tag in your ModelGlue.xml file. Then you can use this code:
Thanks go to Sean for pointing this out. The other option is to use a ConfigBean. Personally this is the option I prefer. This way I can keep my ModelGlue.xml file focused on the events, and put my setting in a separate XML file.
- How do you pass arguments to a view? In the past, I've code layout like so:
I wasn't sure how I would do the same thing in MG. Turns out, you can pass an argument to a view very simply:
<value name="title" value="Welcome to CFLib.org" />
Once you do that, the variable "title" is available in the view state. Of course, my next question was, how do I make it dynamic? You simply use the view state again:
What's cool then is that my view works just fine with either methods, since they both write to the same view state collection.
I have to say - for no real reason I can think - I'm really enjoying the rewrite of CFLib into Model-Glue. I actually tried this once before, with MachII, and I just didn't like it as much. In fact I gave up after a while. I'm not dissing MachII though - I'm just saying that Model-Glue seems to be "sticking" with me a lot better.