Skip navigation.

coldfusion

Organizing ModelGlue Events

|

This may be old news, but did everyone know you can include ModelGlue.xml file within your main modelglue.xml files. The framework has provided an tag within the modelglue config file. you can include as many XML files as you need as long as they are formatted correctly.

The include tag goes after the opening <modelglue> tag and before the first <controller> tag

then you can group the event handlers into multiple files to keep them organized in a logical way.

example:

<modelglue>
            <include template="/config/UserEvents.xml" />
            <include template="/config/AdminEvents.xml" />
            <controllers>

Chaining ModelGlue Generic Commit Events

| |

I have really been loving the generic ORM stuff that is part of ModelGlue 2.0. I had been doing way to much work to stuff the objects we needed into the viewstate. Now I have been able to remove countless listeners and broadcasts I was using to get various objects when needed.
Now a generic read takes care of that.

The basic functionality of the generic events are documented at http://docs.model-glue.com so I wont get into how to use them, but one thing that isn't documented is how to handle updates to multiple unrelated objects in the same form post( event-handler)

Here is how I am doing it, It works like a charm for quick prototyping,as far as I am concerned.

Lets say I have 2 objects, Cinders and Ashes. I am collecting this data on the same form and I need to handle the validation and update the results. I need two generic commit message broadcasts

<message name="modelglue.GenericCommit">
<argument name="object" value="Cinder" />
<argument name="CinderId" value="Cinder" />
</message>

and
<message name="modelglue.GenericCommit">
<argument name="object" value="Ashes" />
<argument name="AshesId" value="Ashes" />
</message>

My form lives at an event called "CindersAndAshes.form" and submits to an event called

Perfect Unity between Model-glue 1 and 2

| | |

I have been working on a gigantic Modelglue 2 app at my day job. to aid in information exchange we had been using canvas wiki (thanks Ray! ). We have been using MG2 since its infancy (original semi-public beta in April).

everything has been working better that expected, however, a few SVN updates ago the wiki stopped working with a Bean creation error. Apparently this is due to the reactor config path.

Since our root site is a Unity app, the reactor bean in the coldspring config looks like this:

<constructor-arg name="pathToConfigXml"><value>/config/Reactor.xml</value></constructor-arg>

When you try to launch the nested app, it doesnt like the path and gives this error:

Bean creation exception during init() of ModelGlue.unity.eventhandler.EventHandlerFactory
Bean creation exception during init() of ModelGlue.unity.orm.ReactorAdapter
The error occurred in C:\Inetpub\wwwroot\WebFiles\coldspring\beans\DefaultXmlBeanFactory.cfc: line 539
Called from C:\Inetpub\wwwroot\WebFiles\coldspring\beans\DefaultXmlBeanFactory.cfc: line 332
Called from C:\Inetpub\wwwroot\WebFiles\ModelGlue\unity\loader\XmlConfigurationLoader.cfc: line 16
Called from C:\Inetpub\wwwroot\WebFiles\ModelGlue\unity\loader\XmlConfigurationLoader.cfc: line 319
Called from C:\Inetpub\wwwroot\WebFiles\ModelGlue\unity\loader\XmlConfigurationLoader.cfc: line 49
Called from C:\Inetpub\wwwroot\WebFiles\ModelGlue\unity\loader\FrameworkLoader.cfc: line 63
Called from C:\Inetpub\wwwroot\WebFiles\ModelGlue\unity\ModelGlue.cfm: line 48
Called from C:\Inetpub\wwwroot\WebFiles\ModelGlue\ModelGlue.cfm: line 1
Called from C:\Sandboxes\Sandbox2\wiki\index.cfm: line 25
537 : <cfthrow type="coldspring.beanCreationException"
538 : message="Bean creation exception during init() of #beanDef.getBeanClass()#"
539 : detail="#cfcatch.message#">
540 : </cfcatch>
541 : </cftry>

How I fixed It

I simply copied the coldspring.xml and reactor.xml to:
webroot/wiki/config
and changed the reactor config constructor-arg to

<constructor-arg name="pathToConfigXml"><value>/wiki/config/Reactor.xml</value></constructor-arg>

I did try to make the path relative ("config/reactor.xml" not /config/reactor.xml") but that didn't seem to work either. Please let me know if there is a better fix!

Syndicate content