Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Model Glue Bean, and multi page form demo app

I've bean(bad pun I know) playing around with makeEventBean in Model Glue.

I was going to do a write up about it, but decided that that took up too much time as it also covered a multi-page form.

[More]

Comments Comments (0) | Print Print | Send Send | 4352 Views

Setting Up Model Glue with no mappings

There was a post on the MG lists about setting up Model Glue and the fact you need mappings. I had this lying around from some internal writings and thought it might be useful. It details setting up MG with no mappings.

[More]

Comments Comments (0) | Print Print | Send Send | 2081 Views

Model Glue Form Validation

I've been working on a app with a couple of forms and wanted to break the validation rules into different group of rules e.g.

1. Rules for address
2. Rules for personal information
3. Rules specific per form.

What this allows me to do is is per validation call in the controller just use the validators i need.

How I am doing it:

1. Create a controller called validator.cfc
2. Create you validation.cfc's i.e.

  1. validator_Personal.cfc
  2. validator_address.cfc
  3. validator_other.cfc

Your validation cfc's should look like this:

view plain print about
1<cfcomponent>
2    <cffunction name="validate" returnType="ModelGlue.Util.ValidationErrorCollection">
3        <cfargument name="formFields">
4
5        <cfset var val = createObject("component", "ModelGlue.Util.ValidationErrorCollection").init() />
6
7        <cfif structKeyExists(formFields, "address1") AND not len(trim(formFields.address1))>
8            <cfset val.addError("address1", "Please enter the first line of your address.") />
9        </cfif>
10    </cffunction>
11</cfcomponent>

[More]

Comments Comments (3) | Print Print | Send Send | 3723 Views

UDF file in Model Glue

This has just came up on the MG Lists and I thought i should post my solution on how I implement a UDF file in MG

1)My UDF file is a component (cfc) on the root of the site. Example UDF:

view plain print about
1<cffunction name="getDateTime">
2    <cfreturn now() />
3</cffunction>

2)Then in my controller (in the onRequestStart):

view plain print about
1<!--- Add a UDF --->
2<cfset variables.udf = createObject("component","pathTo.udf").init()>
3<cfset arguments.event.setValue("udf", variables.udf)>

3)On my view page I have

view plain print about
1<!--- Get UDF --->
2<cfset udf = viewState.getValue('udf') />

Then to call a function

view plain print about
1<cfoutput>#udf.getDateTime()#</cfoutput>

Comments Comments (0) | Print Print | Send Send | 1603 Views

ANT to build Model Glue Project

If you use Eclipse and are creating a lot of Model Glue project check out Wayne Grahams ANT script. Not only does it help you create a MG project quickly, but if like me you don't know ANT all too well its a good guide to creating your own build.xml files.

Comments Comments (0) | Print Print | Send Send | 2496 Views

Escaping characters in model glue xml files

More of a reminder to myself. But when adding text to .xml files (in my case the beans.xml) don't forget to Ascii escape characters like £(&pound;).

You can find a pretty comprehensive Ascii list here http://www.lookuptables.com/

Comments Comments (0) | Print Print | Send Send | 2220 Views

Model Glue : Setting up global variables

Unlike Fusebox there is not a global init variable setting file With MG. If you do need to set up some global vars the way i'm doing this (and seems to be the norm nearly) is:

  1. Set up a cfc called /config/beans/global.cfc
  2. Create an xml file at /config/beans/global.xml - (for my current site this covered about 5-8 small structures/arrays/values that is used through out the site)
  3. In the controller add the following line -
    <cfset variables.global = GetModelGlue().GetConfigBean("global.xml") />
  4. and on request start -
    <cfset arguments.event.setValue("global", variables.global) />

Now on any page to get the variable you want you can use
view plain print about
1<cfset customerTitles = viewState.getValue('global').getTitles() />

I've seen no documentation on this, but have posted to the Topica List. Sean Corfield has another method using a new controller you can find it on the Topica lists also see the GGCC examples (7/8/9) in his frameworks Pod.


For more information on Config beans in MG see :
Eat Your Beans: ConfigBeans in Model-Glue

Comments Comments (1) | Print Print | Send Send | 2616 Views

Model Glue Controller config explained

Below is a quick run down of the config.xml setting in Model Glue, though i would like to take credit :o) i got this from the MG lists, posted by Doug Hughes

Here's a rundown of the settings:

<setting name="applicationMapping" value="/" />


This is where your application is located. If it's in a subdirectory (or a
mapping put that here.
<setting name="beanMappings" value="/config/beans/" />


[More]

Comments Comments (0) | Print Print | Send Send | 1875 Views

A start using Model Glue pt2 - still theory

So you've decided that you can handle building this huge app comprising of 1 page and want to carry on. Well its time to throw in a little more theory first. Sorry.

We've seen the flow and now need to think of the structure. Simple. We need:

  • 1 x form - dsp.frm.details.cfm
  • 1 x page to let the user know its all ok- dsp.successful.cfm
  • 1 x validation CFC - validator.cfc
  • 1 x user CFC to insert the data into the DB - users.cfc

[More]

Comments Comments (0) | Print Print | Send Send | 1142 Views

A start using Model Glue pt1

After a couple of false starts i'm finally getting my head down and into Model Glue(MG) - you know, the framework that a few people have mentioned on their blogs :o). Why now? is it to jump on a band wagon? Is it because ver 1.0 has now gone stable? Sorry no, its because i want to learn it, and have a small (very small) app to do, and where better to start?

[More]

Comments Comments (0) | Print Print | Send Send | 1957 Views

Model-Glue xml DTD

Sitting in the hotel room last night i finally started getting into Model-Glue - Something i've been meaning to do for ages. Using Cfeclipse i got through half the quickstart guide when i got side tracked thinking that the XML file should have a DTD file for validation - something else i've been wanting to get into for ages since noticing the minor glitches in the FB ones.

So after some digging around the web i ended up creating the following file: modelglue.dtd

If you currently dont have a XML editor for Eclipse - i'm currently using XML Buddy which has been working well.

Comments Comments (0) | Print Print | Send Send | 1445 Views

Previous Entries

BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .