| Version 2 (modified by cfgrok, 16 years ago) |
|---|
Section 8: Extending Model-Glue
The Model-Glue framework is highly extensible. If you don't like the way Model-Glue handles a certain function, you can override Model-Glue. This is a simple process because Model-Glue uses ColdSpring under the covers. In this walk-through, we will make Model-Glue use a custom scaffold template without actually modifying Model-Glue framework files.
- Create a new directory in /PlantOMatic/model called scaffoldTemplates
- Open /ModelGlue/gesture/modules/scaffold/beans, copy the following files and paste them into the newly created scaffoldTemplates directory:
- /ModelGlue/gesture/modules/scaffold/beans/Edit.cfc
- /ModelGlue/gesture/modules/scaffold/beans/List.cfc
- Open each file and change the name attribute in the view tag:
<view name="body" template...
To:
<view name="primary" template...
- Open /PlantOMatic/config/ModelGlue.xml and add the following tag after the closing </event-types> tag:
<scaffold object="Plant" event-type="templatedPage" />
- Next, open /PlantOMatic/config/ColdSpring.xml and change:
<property name="rescaffold"><value>false</value></property>
To:
<property name="rescaffold"><value>true</value></property>
- In the same ColdSpring.xml file paste in the following XML:
<bean id="modelglue.scaffoldType.Edit" class="coldspring.beans.factory.config.MapFactoryBean">
<property name="SourceMap">
<map>
<entry key="class"><value>PlantOMatic.model.scaffoldTemplates.Edit</value></entry>
<event key="hasXMLGeneration"><value>true</value></event>
<event key="hasViewGeneration"><value>true</value></event>
<entry key="prefix"><value>Form.</value></entry>
<entry key="suffix"><value>.cfm</value></entry>
</map>
</property>
</bean>
<bean id="modelglue.scaffoldType.List" class="coldspring.beans.factory.config.MapFactoryBean">
<property name="SourceMap">
<map>
<entry key="class"><value>PlantOMatic.model.scaffoldTemplates.List</value></entry>
<event key="hasXMLGeneration"><value>true</value></event>
<event key="hasViewGeneration"><value>true</value></event>
<entry key="prefix"><value>List.</value></entry>
<entry key="suffix"><value>.cfm</value></entry>
</map>
</property>
</bean>
Putting It All Together
Test your code by visiting http://localhost/PlantOMatic/?event=Plant.List
You should have a list of plants using the custom look and feel of our PlantOMatic application:

Plant List
In this walk-through we overrode default behavior of the Model-Glue framework simply by using ColdSpring. The reason why this worked is because Model-Glue uses ColdSpring internally to configure itself. Since beans in ColdSpring are referenced by name, and because application specific ColdSpring bean definitions load after the Model-Glue internal definitions, you can override pretty much any behavior of Model-Glue. If you want to find the names of overridable beans look in /ModelGlue/gesture/configuration/ModelGlueConfiguration.xml.
Attachments
-
training08-1.png
(94.4 kB) - added by cfgrok
16 years ago.
Training 08 Image 1
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)