Changes between Version 2 and Version 3 of Training/Section08

Show
Ignore:
Timestamp:
01/26/12 16:07:59 (14 years ago)
Author:
DanWilson (IP: 98.26.77.109)
Comment:

Added Bonus Points section to show how to make custom generational patterns

Legend:

Unmodified
Added
Removed
Modified
  • Training/Section08

    v2 v3  
    9292In 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. 
    9393 
     94 
     95== Bonus Points == 
     96For bonus points, you can take the additional step of creating a new Scaffolding template in Model Glue. This is really simple to do and we'll leave it for your homework. If you get stuck, simply post to the [http://groups.google.com/group/modelglue Model Glue Mailing List] and we'll sort you out. 
     97 
     98 
     99For this exercise, you will need to: 
     100 1. Make a copy of the List.cfc located at PlantOMatic.model.scaffoldTemplates.List. Name the copy Grid.cfc.  
     101 2. Open the new Grid.cfc and go to the loadViewTemplate() method. Add the word GRID after the Breadcrumbs just so you can verify the new Grid is working. 
     102 
     103{{{ 
     104<div id="breadcrumb"><a href="##listEvent##">%spaceCap( Metadata.alias )%</a> GRID</div> 
     105}}} 
     106 
     107 3. Then wire up the new Grid.cfc in your /PlantOMatic/config/ColdSpring.xml. This will include configuring the Grid with a bean called: PlantOMatic.scaffoldTemplate.Grid as well as using some ColdSpring functionality to load the new bean into the modelGlue.scaffoldManager  
     108 
     109{{{ 
     110 
     111<!-- Load the new Grid Scaffold Template into the Model Glue framework --> 
     112<bean id="ScaffoldTemplate.Grid"  factory-bean="modelglue.scaffoldManager" factory-method="addScaffoldTemplate" lazy-init="false">   
     113        <constructor-arg name="scaffoldBeanRegistry">   
     114                        <list> 
     115                                <ref bean="PlantOMatic.scaffoldTemplate.Grid" /> 
     116                        </list>  
     117        </constructor-arg>   
     118</bean> 
     119<!-- Configure the new Grid.cfc -->      
     120<bean id="PlantOMatic.scaffoldTemplate.Grid" class="coldspring.beans.factory.config.MapFactoryBean"> 
     121        <property name="SourceMap"> 
     122                <map> 
     123                        <entry key="class"><value>PlantOMatic.model.Grid</value></entry> 
     124                        <event key="hasXMLGeneration"><value>true</value></event> 
     125                        <event key="hasViewGeneration"><value>true</value></event> 
     126                        <entry key="prefix"><value>Grid.</value></entry> 
     127                        <entry key="suffix"><value>.cfm</value></entry> 
     128                </map> 
     129        </property> 
     130</bean>          
     131}}} 
     132 
     133 4. Lastly, add a second scaffold tag for Plant to your /PlantOMatic/config/ModelGlue.xml with the type of Grid so we can get the new Grid to generate: 
     134 
     135{{{ 
     136<scaffold object="Plant" type="Grid"  event-type="templatedPage" /> 
     137}}} 
     138 
     139Test your code by visiting [http://localhost/PlantOMatic/?event=Plant.Grid http://localhost/PlantOMatic/?event=Plant.Grid]. Notice the GRID string in the breadcrumbs. You can make many uses of this, from implementing a JQuery Datatables Grid, Generating Pie Charts, Bar Charts, and any number of interesting patterns applied to your table objects. If you do something interesting with this feature, or just have a general comment, please let us know on the [http://groups.google.com/group/modelglue Model Glue Mailing List]. 
     140 
     141 
    94142---- 
    95143 
     144 
    96145Back: [wiki:Training/Section07 Training Section 7: Crossing the Generational Gap]