Step 1: Set Up

	Main Points: 	Explain Lightpost
							Explain Presentation
							No Chrome
							No Data
	*************************************************							
Step 2: Implicit Controller Calls

	Main Points:	Broadcast/Listener pattern
							Broadcast/No Listener implications ( Conversation with no one listening to a certain person)
													
	Code:					 
		
<message-listener message="getEntries" function="getEntries" />
<message name="getEntries" />
			
then remove the function="getEntries" to show the automapping 			
			
	*************************************************			
Step 3: Beans Scope 

		Trace the flow, to the controller. Dump beans scope, and show entries in the ColdSpring Factory.
	Main Points: 	Integration with ColdSpring for Factory, Dependency Injection and Inversion of Control 
							Easy shortcut, good autodocumentation
	Code:

		<cfdump var="#beans#"><cfabort>
		
	*************************************************		
Step 4: Event Types
	Main Points: 	Reusable processing around an event handler.

	Code:

		<event-type name="hasAuthentication">
			<before>
				<broadcasts>
					<message name="needAuthenticatedUser" />
				</broadcasts>
			</before>
		</event-type> 
		<event-type name="hasStandardLayout">
			<after>
				<views>
					<include name="contentRight" template="categories.cfm">
						<value name="xe.delete" value="categories.Delete" overwrite="true" />
						<value name="xe.edit" value="categories.Edit" overwrite="true" />
					</include>
					<include name="contentRight" template="bookmarks.cfm" append="true">
						<value name="xe.delete" value="bookmarks.Delete" overwrite="true" />
						<value name="xe.edit" value="bookmarks.Edit" overwrite="true" />					
					</include>
					<include name="main" template="mainLayout.cfm" />
				</views>
			</after>
		</event-type>
		
then Decorate the view pages with the event type
	 Main Points: 	Multiple Event Types are fine (comma delimited)
	 						Good Autodocumentation
	 
 	type="hasStandardLayout">
	 
then load page	 
then log in and  Open Categories.cfm 

	Main Points:	Exit Events Lead to Well documented Blueprint
							CopyToScope Reduces boilerplate code 
							LinkTo keeps linking schemes in sync (change eventName in ColdSpring for fun)
							
	
	Explain the exit event paradigm and explain the values in the category include. 
	Then also show how to get bulk values out of the event with copyToScope(). and how to create a URL Link with linkTo()
	

	<cfset event.copyToScope( variables, "xe.delete,xe.edit") />
	<cfset handleDelete = event.linkTo( xe.delete ) />
	<cfset handleForm = event.linkTo( xe.edit ) />
	
	*************************************************	 
	
	
Step 5: Scaffolding and Custom Scaffolding

Click Category Edit Pencil. Show it not working because there is no code. Then add scaffold tag and watch it work magically.

then flip rescaffold to true

then add scaffold code:
	<scaffold object="categories" />	
	<scaffold object="bookmarks" />		

then reload page and show generated code. Point out the lack of a skin. 
then Custom Generation Patterns to the Rescue
		
then copy Scaffold.cfcs for List and Edit, add the event type
	
	type="hasStandardLayout"
			  
then change the name of the content area from Body to Content.
then link them inside coldspring.
		
<bean id="modelglue.scaffoldType.Edit" class="coldspring.beans.factory.config.MapFactoryBean">
	<property name="SourceMap">
		<map>
			<entry key="class"><value>mgpost.model.scaffoldTemplates.Edit</value></entry>
			<event key="hasXMLGeneration"><value>true</value></event>
			<event key="hasViewGeneration"><value>true</value></event>
			<entry key="prefix"><value>edit</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>mgpost.model.scaffoldTemplates.List</value></entry>
			<event key="hasXMLGeneration"><value>true</value></event>
			<event key="hasViewGeneration"><value>true</value></event>
			<entry key="prefix"><value></value></entry>
			<entry key="suffix"><value>.cfm</value></entry>
		</map>
	</property>
</bean>
	
	
then set rescaffold to false, 
then copy out the event handlers into the main model glue xml file, 
then	delete the scaffold.xml fie 
then run the application again.

	*************************************************	 
		
Step 6: RequestFormats:
	Main Ideas: 		Some events serve multiple purposes and need different layouts.
							ModelGlue lets you conditionally include view templates and layouts according to a passed in requestformat flag.

		
then replace the views section of the hasStandardLayout
	
				<views format="html"> 
									
then open entries and add the link
<a href="#handleHome#&entryID=#entry.getEntryID()#&requestformat=print" onclick="return popPrintWindow( this.href);">[ Print Friendly View ]	</a>

	
then reload and click link.
	*************************************************	 
	
Step 7: Helpers
	Main Ideas: 		UDFs sometimes need to be accessed inside the application, but don't have a place to live.
							ModelGlue introduces the concept of a helper which allows a UDF to be made part of the MG event and can be used in controllers and views.


Create a new helpers directory.

Then link it in the coldspring configuration.

	/mgpost/helpers,

Then make a new .cfm file called date.cfm with the body of:
<cfscript>
/**
* Calculates the number of business days between 2 dates.
*
* @param date1      First date. (Required)
* @param date2      Second date. (Required)
* @return Returns a number.
* @author Harry Goldman (harry@icn.net)
* @version 1, April 10, 2008
*/
function businessDaysBetween(date1,date2) {
    var numberOfDays = 0;
    
    while (date1 LT date2) {
        date1 = dateAdd("d",1,date1);
        if(dayOfWeek(date1) GTE 2 AND dayOfWeek(date1) LTE 6) numberOfDays = incrementValue(numberOfDays);
    }

    return numberOfDays;
}
</cfscript>

then add in entries.cfm
	 #helpers.date.businessDaysBetween( entry.getEntryDate(), now() )# business days ago
	 
Then run code and show the linkage.
	*************************************************	 
Step 8: Event Generation
	Main Ideas: 	Much new development is in creating an Event Handler, a message listener a controller function and a view.
						ModelGlue (if you let it) will create all of the skeleton code for you, at the flick of a switch.

turn on event generation on in the coldspring file.

Access the URL event=categoryRSS

Open the Controller and overwrite the Category RSS function with the below.

	beans="RSSConfiguration,rssService"


	<cffunction name="categoryRSS" output="false" hint="Returns the RSS for the entire blog. By default returns the same entries displayed on the home page. For a categoryu returns the most recent 20.">
		<cfargument name="event" type="ModelGlue.Core.Event" required="true">
		<cfset var rssArgs = structNew() />
		<cfset var rss = ""/>
		<cfset structAppend( rssArgs, beans.RSSConfiguration ) />
		<cfset rssArgs.categoryID = event.getValue("categoryID",0)/>
		<cfset rssArgs.categoryName = "Category: " & event.getValue("categoryName","")/>
		
		<cfif val( rssArgs.categoryID ) GT 0>
			<cfset rss = beans.rssService.getCategoryRSS( argumentcollection:rssArgs ) />
		<cfelse>
			<cfset rss = beans.rssService.getBlogRSS( argumentcollection:rssArgs ) />
		</cfif>
	
		<cfset arguments.event.setValue("rss", rss) />
	</cffunction>
	
then paste in the following for the view.
<cfcontent type="text/xml"><cfoutput>#event.getValue("rss")#</cfoutput>


	