Changes between Initial Version and Version 1 of Training/Section08

Show
Ignore:
Timestamp:
12/29/09 21:34:56 (16 years ago)
Author:
cfgrok (IP: 64.30.223.5)
Comment:

Adding new training section

Legend:

Unmodified
Added
Removed
Modified
  • Training/Section08

    v1 v1  
     1[[TOC(heading=Training Section Contents, Training*)]] 
     2 
     3= Section 8: Extending Model-Glue = 
     4 
     5The 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. 
     6 
     7 1. Create a new directory in /PlantOMatic/model called scaffoldTemplates 
     8 2. Open /ModelGlue/gesture/modules/scaffold/beans, copy the following files and paste them into the newly created scaffoldTemplates directory: 
     9 
     10     * /ModelGlue/gesture/modules/scaffold/beans/Edit.cfc 
     11     * /ModelGlue/gesture/modules/scaffold/beans/List.cfc 
     12 
     13 3. Open each file and change the name attribute in the view tag: 
     14 
     15{{{ 
     16 
     17<view name="body" template... 
     18 
     19}}} 
     20 
     21    To: 
     22 
     23{{{ 
     24 
     25<view name="primary" template... 
     26 
     27}}} 
     28 
     29 4. Open /PlantOMatic/config/ModelGlue.xml and add the following tag after the closing </event-types> tag: 
     30 
     31{{{ 
     32 
     33<scaffold object="Plant" event-type="templatedPage" /> 
     34 
     35}}} 
     36 
     37 5. Next, open /PlantOMatic/config/ColdSpring.xml and change: 
     38 
     39{{{ 
     40 
     41<property name="rescaffold"><value>false</value></property> 
     42 
     43}}} 
     44 
     45    To: 
     46 
     47{{{ 
     48 
     49<property name="rescaffold"><value>true</value></property> 
     50 
     51}}} 
     52 
     53 6. In the same !ColdSpring.xml file paste in the following XML: 
     54 
     55{{{ 
     56 
     57<bean id="modelglue.scaffoldType.Edit" class="coldspring.beans.factory.config.MapFactoryBean"> 
     58  <property name="SourceMap"> 
     59    <map> 
     60      <entry key="class"><value>PlantOMatic.model.scaffoldTemplates.Edit</value></entry> 
     61      <event key="hasXMLGeneration"><value>true</value></event> 
     62      <event key="hasViewGeneration"><value>true</value></event> 
     63      <entry key="prefix"><value>Form.</value></entry> 
     64      <entry key="suffix"><value>.cfm</value></entry> 
     65    </map> 
     66  </property> 
     67</bean>  
     68 
     69<bean id="modelglue.scaffoldType.List" class="coldspring.beans.factory.config.MapFactoryBean"> 
     70  <property name="SourceMap"> 
     71    <map> 
     72      <entry key="class"><value>PlantOMatic.model.scaffoldTemplates.List</value></entry> 
     73      <event key="hasXMLGeneration"><value>true</value></event> 
     74      <event key="hasViewGeneration"><value>true</value></event> 
     75      <entry key="prefix"><value>List.</value></entry> 
     76      <entry key="suffix"><value>.cfm</value></entry> 
     77    </map> 
     78  </property> 
     79</bean> 
     80 
     81}}} 
     82 
     83== Putting It All Together == 
     84 
     85Test your code by visiting [http://localhost/PlantOMatic/?event=Plant.List http://localhost/PlantOMatic/?event=Plant.List] 
     86 
     87You should have a list of plants using the custom look and feel of our PlantOMatic application: 
     88 
     89[[Image(training08-1.png, nolink)]][[BR]] 
     90'' Plant List '' 
     91 
     92In 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. 
     93 
     94---- 
     95 
     96Back: [wiki:Training/Section07 Training Section 7: Crossing the Generational Gap]