| | 94 | |
| | 95 | == Bonus Points == |
| | 96 | For 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 | |
| | 99 | For 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 | |
| | 139 | Test 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 | |