fusiongrokker

Entries Tagged as Model-Glue

My Custom URL Managers for Model-Glue 3

It recently came up on the Model-Glue mailing list that the baked-in URL Managers in Model-Glue 3 could be a little bit better. In particular, the way they work is that you use the LinkTo function and pass it the event name that you want to link to as well as the name of the parameters that should go in the URL. Their values have to be variables stored in the event — so they could come from a form post, a controller, or if need be, you can set them in your view immediately before use like so:

I found this to be a little bit clumsy in some cases — mostly when I would have done the above, to set the values from the view — and apparently I'm not alone; so I figured I would go ahead and post my custom URL Manager CFCs for you here.

My changes are not that significant, and really only build on the existing functionality (which is left in place for cases where I still want to use it) so that if the second argument to the LinkTo function is a structure instead of a string, I use the key/value pairs from it to populate the link, instead of keys from the string and values from the event.

To use this, save it as a CFC in your Model-Glue application somewhere, and change the default bean definition in your ModelGlue.xml file to point to the new file instead of the default one:

And here is the code for my basic URL Manager CFC:

To make this into an SES URL Manager, you just need to change the formatUrlParameter function definition to be something like the this:

Posted in Model-Glue | No Responses Yet February 09 2009

Model-Glue 2 Cheat Sheet

Someone by the name of Nando posted his Model-Glue cheat sheet to the Model-Glue discussion group. I took the time to clean it up and make it a little more readable, and fit onto two pages. I've printed it out as front and back of a single page, and keep it with my laptop for reference. I think I'll also add it to my sidebar for easy reference. Thanks to Nando for doing the leg work. I just made it pretty! Click the thumbnail to download the PDF.

Posted in Frameworks | Model-Glue June 26 2008

Improve Model-Glue 3 Load Time: Remove Unwanted Helpers

I've been spending a fair amount of time playing with the latest Release Candidate of Model-Glue 3 lately, and I've stumbled on a way to vastly improve load time.

One of the new features of MG3 is "helpers", which is an easy way to make UDFs available throughout your applications. It really does make working with UDFs in Model-Glue easier, but there's one problem: It comes packaged with hundreds and hundreds of them. In fact – almost every single UDF on CFLib! And especially on your development server, where you're likely to reload the entire framework on every request loading them takes a good long time.

If you prefer to hand-pick which UDFs to include – as I do – you have a couple of options. The simplest is to edit your config/coldspring.xml file, and remove the reference to the packaged helpers:

<property name="helperMappings"><value>/helpers,/ModelGlue/helpers</value></property>

becomes:

<property name="helperMappings"><value>/helpers</value></property>

Now you can selectively put UDFs that you want to use into your /helpers folder and have access to them without having to tack an extra 10 seconds onto the load of every page.

Posted in ColdFusion | Frameworks | Model-Glue May 30 2008

Making New Toys Play Nice: Model Glue 3 & Open Blue Dragon

If you're like me (a glutton for spiffy new technology, and even more-so when it's free) then you've played around with Open Blue Dragon, and probably the latest release candidate for Model Glue 3. Unfortunately, they don't play nicely with each other out of the box. In this post, I'll document everything I've done in order to make MG3 run on OpenBD.

For reference, I'm running the Jetty-server-included version of OpenBD on Debian, against MySQL — which, by the way, is an awesome way to get a development environment up and running in no time flat!

The first problem I hit was this error: Bean creation exception during init() of ModelGlue.gesture.modules.internal.generation.service.XMLEventGenerationService MG3 error on OpenBD

After a little searching around, I found this post on the Model-Glue discussion group, where the issue reporter was describing almost exactly the same issue, and the response by Dan Wilson was that MG3 requires some of the new functionality packaged with ColdFusion 8 — but that he had submitted a bug report for it in the MG bug tracker, and provided a modified version of the file in question that uses a work-around for the issue. I tried this file and it resolved my issue. Dan says that the resulting XML may not be very pretty, but this is at least a starting point and might be improved on. Once you've gotten that resolved, you'll find that Model-Glue is throwing errors while loading itself.

Model-Glue 3 includes something called "helpers" which appears to mostly be a collection of UDFs; and this will be where your errors are happening. If you don't intend to use any of the helpers (or can/will copy any needed functions into your application manually), you can just delete the .cfm files in /ModelGlue/helpers/ and skip the rest of this step. Otherwise, what you'll need to do is run each helper file as if it were one of your pages, individually, and resolve all of the errors it throws. I will include downloads for any files I modified for this post.

OpenBD has some functions defined (CharAt, listRemoveDuplicates, etc) that aren't defined in Adobe ColdFusion CFML — these you can just comment out — and you'll also find some syntax like !=, ++, <=, and % that will need to be converted to neq, mod, lte, etc. NOTE: The baked in functions that collide with UDFs may not work the same way as the ones you're commenting out, so be sure to either look up their documentation, or thoroughly test before you rely on them. I changed: StrLib.cfm, DataManipulationLib.cfm, and DatabaseLib.cfm (switched a cfscript-style comment outside of a cfscript block to a normal CFML comment). Once each of these files will run individually without error, try your index.cfm again and you should see everything up and running!

As promised, here are the three files I modified. Don't forget to grab the modified copy of CGCodeGenerator.cfc from this post. I see that these helper issues have also been logged as bugs, so hopefully they will all be resolved before a final version is released.

MG3 working on OpenBD

UPDATE 5/30: At this point, it looks like code generation just doesn't want to work on Open Blue Dragon. Sean Corefield responded to a post of mine on the model-glue mailing list about it not working, and says that Joe is aware of the issue (with another Java class used) and plans to rewrite the code without using these problem classes at some point. Hopefully we'll see them fixed before a final release.

Posted in ColdFusion | Frameworks | Model-Glue | OpenBD May 27 2008