<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>n42 Designs - FarCry</title>
<link>http://www.n42designs.com/blog/index.cfm</link>
<description>n42 Designs Blog</description>
<language>en-us</language>
<pubDate>Sun, 05 Sep 2010 04:49:50 -0400</pubDate>
<lastBuildDate>Fri, 20 Jul 2007 15:04:00 -0400</lastBuildDate>
<generator>BlogCFC</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<managingEditor>sean@n42designs.com</managingEditor>
<webMaster>sean@n42designs.com</webMaster>
<itunes:subtitle></itunes:subtitle>
<itunes:summary></itunes:summary>
<itunes:category text="Technology" />
<itunes:category text="Technology">
<itunes:category text="Podcasting" />
</itunes:category>
<itunes:category text="Technology">
<itunes:category text="Tech News" />
</itunes:category>
<itunes:keywords></itunes:keywords>
<itunes:author></itunes:author>
<itunes:owner>
<itunes:email>sean@n42designs.com</itunes:email>
<itunes:name></itunes:name>
</itunes:owner>
<itunes:image href="" />
<image>
<url></url>
<title>n42 Designs</title>
<link>http://www.n42designs.com/blog/index.cfm</link>
</image>
<itunes:explicit>no</itunes:explicit>
<item>
<title>Integrate a Model-Glue
Application into FarCry</title>
<link>http://www.n42designs.com/blog/index.cfm/2007/7/20/Integrate-a-ModelGlue-Application-into-FarCry</link>
<description>
I&apos;m sure there are other ways to do this but
this is how I was able to integrate an existing Model-Glue application
into a FarCry site. I am using ModelGlue 2.0, the latest ColdSpring BER
as of this posting, and the latest beta of reactor.
My MG app in
question is a events calendar. Its a pretty simple application using
MG, Reactor, and ColdSpring.
Because I don&apos;t want to use ColdFusion
mappings (and its running on CF7 so no per application mappings) I
copied modelglue, reactor, and coldspring into
{farcry_root}/projects/{site_name}/www as www/modelglue, www/reactor,
and www/coldspring.
If you are using mappings you can skip that
step.
Next, I created a simple include file called _mgCal.cfm in
{farcry_root}/projects/{site_name}/includedObj.
The code for this is
as follows:
&lt;code&gt;
&lt;!--- @@displayname: Calendar ---&gt;
&lt;cfsetting
enablecfoutputonly=&quot;no&quot;&gt;
&lt;cfinclude template=&quot;/mg/mgCal/index.cfm&quot;
/&gt;
&lt;cfsetting enablecfoutputonly=&quot;no&quot;&gt;
&lt;/code&gt;
Now, in the FarCry
webtop, under the site tab, navigate to the root node, and under
utility, create a new navigation node called &quot;Calendar&quot; and under that,
a new include called &quot;Calendar&quot;.
Publish both. The friendly URL
should be /go/calendar, but it can be whatever you like.
Now we have
to copy our MG application into the site tree. Create a new folder
called &quot;mg&quot; under the www folder. This is where all my MG apps will
live. So I copy my &quot;mgCal&quot; folder from my test site into the &quot;mg&quot;
folder I just created giving me a directory structure like
so:
&lt;pre&gt;
/www/mg/mgCal/
/www/mg/mgCal/config
/www/mg/mgCal/controller
/www/mg/mgCal/model
/www/mg/mgCal/views
/www/mg/mgCal/Application.cfm
/www/mg/mgCal/index.cfm
etc
&lt;/pre&gt;
Now
we have a few modifications to make to the MG app to get it to run from
this location. Depending on how you first created the MG app, your
settings may be different.
In your MG App&apos;s index.cfm file add the
following line above the &amp;lt;cfinclude&amp;gt; that calls
Model-Glue.
&lt;code&gt;
&lt;cfset ModelGlue_LOCAL_COLDSPRING_PATH =
getDirectoryFromPath(getCurrentTemplatePath()) &amp;
&quot;/config/ColdSpring.xml&quot; /&gt;
&lt;/code&gt;
Now MG can find your ColdSpring
configuration file.
In your ColdSpring configuration file edit the
following properties:
In your modelGlueConfiguration bean:
The
paths should be straight forward, but your defaultTemplate property must
be set to the FriendlyURL of your include.
&lt;code&gt;
&lt;property
name=&quot;viewMappings&quot;&gt;&lt;value&gt;/mg/mgCal/views&lt;/value&gt;&lt;/property&gt;
&lt;property
name=&quot;generatedViewMapping&quot;&gt;&lt;value&gt;/mg/mgCal/views/generated&lt;/value&gt;&lt;/property&gt;
&lt;property
name=&quot;configurationPath&quot;&gt;&lt;value&gt;/mg/mgCal/config/ModelGlue.xml&lt;/value&gt;&lt;/property&gt;
&lt;property
name=&quot;scaffoldPath&quot;&gt;&lt;value&gt;/mg/mgCal/config/scaffolds/Scaffolds.xml&lt;/value&gt;&lt;/property&gt;
&lt;property
name=&quot;defaultTemplate&quot;&gt;&lt;value&gt;/go/calendar&lt;/value&gt;&lt;/property&gt;
&lt;/code&gt;
In
your reactorConfiguration bean:
&lt;code&gt;
&lt;constructor-arg
name=&quot;pathToConfigXml&quot;&gt;&lt;value&gt;/mg/mgCal/config/reactor/Reactor.xml&lt;/value&gt;&lt;/constructor-arg&gt;
&lt;property
name=&quot;mapping&quot;&gt;&lt;value&gt;/mg/mgCal/model/data/reactor&lt;/value&gt;&lt;/property&gt;
&lt;/code&gt;
You
will want the paths to match those you set up in the previous
steps.
Now for the tedious part. This was easy for me since I only
have a few views, but a complex app with a large number of views will
probably be a bit more work.
In each view that calls
#viewState.getValue(&apos;myself&apos;)# you will have to, prior to any of those
calls run the following statement:
&lt;code&gt;
&lt;cfset
viewState.setValue(&apos;myself&apos;,replace(viewState.getValue(&apos;myself&apos;),&apos;?&apos;,&apos;&amp;amp;&apos;,&apos;ALL&apos;))
/&gt;
&lt;/code&gt;
This is to prevent a url like
/go/calendar?event=some.mgEvent from happening. The friendlyURL is
hiding some other FarCry
URL variables. So there is already a ? in
the URL. This will replace the ? that MG creates with an ampersand so
you can attach the MG url variables. easily.
Thats all it took to get
my simple calendar MG app running under FarCry. A more complex app may
need more to get running, but at least this will get you started.
If
any one has any suggestions on a better way to handle this, I am all
ears. I tried to find another instance of someone doing this in both
the &lt;a href=&quot;http://groups.google.com/group/farcry-dev&quot;&gt;FarCry&lt;/a&gt; and
&lt;a href=&quot;http://groups.google.com/group/Model-Glue&quot;&gt;Model-Glue&lt;/a&gt; lists
to no avail.
</description>
<category>Model-Glue</category>
<category>FarCry</category>
<pubDate>Fri, 20 Jul 2007 15:04:00 -0400</pubDate>
<guid>http://www.n42designs.com/blog/index.cfm/2007/7/20/Integrate-a-ModelGlue-Application-into-FarCry</guid>
</item>
</channel></rss>