Introduction to Model-Glue Rachel Lehman Perpetual Intermediate Designer-Developer Introduction to Model-Glue | Rachel Lehman1
Model-Glue:ColdFusion An MVC Framework for ColdFusion Open Source Also does scaffolding Works well with other frameworks (and uses them) Simple enough for beginners Powerful enough for enterprise development Introduction to Model-Glue | Rachel Lehman2
Agenda What a Model-Glue application looks like What the framework does Installation & configuration Hello World example Master-Detail example A few handy tips Upcoming in Model-Glue 3 Q & A Introduction to Model-Glue | Rachel Lehman3
Basic Model-Glue Application Architecture Model (CFC business objects & data access) CFCs for business objects (Beans) CFCs for data access (DAOs & Gateways) CFCs for service abstraction (Service layer) View (CFM display code) CFM pages for view templates (dspIndex.cfm, dspTemplate.cfm, dspMyPage.cfm) Common includes (headers, footers, UDF’s, etc) Where the HTML goes Controller (CFC business logic) CFCs to connect your views to your model Configuration (XML defining your application) ColdSpring.xml defines ModelGlue application settings ModelGlue.xml defines the pages (events) in your application ORM Configuration: Reactor and Transfer (required for scaffolding) Application.cfm (soon to be Application.cfc, defines app name) Index.cfm (front controller, imports framework, all requests go through here) Introduction to Model-Glue | Rachel Lehman4
Model-Glue Event Flow Introduction to Model-Glue | Rachel Lehman5
Installation Download MG from Download ColdSpring from Download Reactor from or Transfer from Unzip files and copy the framework files to your web root, or what ColdFusion sees as /modelglue, /coldspring, /reactor (with mappings if necessary) Copy the modelglueapplicationtemplate directory to where you wish to deploy your application Introduction to Model-Glue | Rachel Lehman6
Configuration Open the build.xml file – ANT build file Edit the project name, application name, and application directory Run the file as an ANT build (either through Eclipse, or the command line with ANT) Introduction to Model-Glue | Rachel Lehman7
No Ant? Don’t be intimidated, it’s super simple and comes with Eclipse (you have it if you’re using CFEclipse) You can also follow these steps for a manual install: – Create a new directory called "myappname" under your Web root. – Copy the contents of the /modelglueapplicationtemplate directory to the /myappname directory. – Open /myappname/config/ColdSpring.xml – Do a find and replace, changing "modelglueapplicationtemplate" to "myappname" – Open /myappname/config/ModelGlue.xml – Do a find and replace, changing "modelglueapplicationtemplate" to "myappname" – Open /myappname/Application.cfm – Do a find and replace, changing "modelglueapplicationtemplate" to "myappname" Introduction to Model-Glue | Rachel Lehman8
Here Goes Nothin! Browse to the home page of your application, and you should see… Introduction to Model-Glue | Rachel Lehman9
What You Should Know About Configuration (ColdSpring.xml) Reload (true for development, false for production) & reload password (defaults to true) Rescaffold (true for development when using scaffolding, false otherwise and for production) Debug (true for development, false for production) Preferences, Names for common terms (default event/page, event name, reload key, etc) Mappings to files (views, scaffolds, config, etc) Introduction to Model-Glue | Rachel Lehman10
DEMO: HELLO WORLD Adding and running a new event Introduction to Model-Glue | Rachel Lehman11
A Few Tips Force application reload with init=true Get the current page and event name (base URL) with viewState.getValue(‘myself’) Forward events within the Controller (like but within the framework) with event.forward() for redirection It’s event within the Controller, and viewState within the views* Centralize application settings with GenericConfig beans Create multiple view templates for different layouts or types of delivery (home, subpage, popup, rss, etc) Add an unnamed result to the xml and it will execute at the end of the request for easy site-wide templates Lock down your config files (store outside the web root and use a mapping, or apply directory security) and if possible, the framework itself. Introduction to Model-Glue | Rachel Lehman12
DEMO: MASTER/DETAIL APPLICATION (CF ART GALLERY) An application put into practice with Model-Glue Introduction to Model-Glue | Rachel Lehman13
From Here… You can organize and divide your application with multiple – Controllers – ModelGlue.xml config files – ColdSpring.xml config files ActionPacks are pluggable Model-Glue applications Check out Generic Database Messages and Scaffolds features for quick admin interfaces Introduction to Model-Glue | Rachel Lehman14
Now in Alpha Model-Glue: Gesture Feature Preview Event generation – type the name of an event that doesn’t exist, and your stub XML, controller methods, views and even a unit test case will be generated for you Custom-typed events allow you to bundle repetitive event functionality (templates) into the event, rather than defining it with each event handler in your xml Application.cfc support (CFMX6 has been EOL’d) All event values are now stored in the Event object, no need to use viewState Easy ways to manage search engine safe URLs Helpers – for an easier way to include UDFs Dead-simple caching (in event xml – cache=true) – extendable for you to implement on your own Estimated release is Mid 2008 Introduction to Model-Glue | Rachel Lehman15
Resources and Further Reading ModelGlue mailing list (Google Groups ID- model-glue) Documentation: Joe Rinehart’s Blog: the author of Model-Glue Ray Camden’s Blog: intro series, answers to many FAQ’s: Other Blogs that cover Model-Glue: – Todd Sharp - – Doug Boude - – Dan Wilson - Model-Glue Cookbook: Demo applications written with Model-Glue: – Canvas wiki: – Litepost blog: – Sample apps with MG install Apache ANT for deployment - I’ll post my code examples on my own blog at Introduction to Model-Glue | Rachel Lehman16
Q & A Thank you! Introduction to Model-Glue | Rachel Lehman17