150 likes | 173 Views
Learn how to break down and simplify your application using Fusebox Application Object Model. Connect circuit applications, utilize Enterprise Java Beans, and leverage JavaScript Document Object Model for effective communication. Discover the benefits of Application Object Model in ColdFusion to streamline variable storage. Improve your application structure, set global variables, and enhance integration with App_Model.cfm. Embrace standardization for smoother development and join the discussion at Fusebox.org for further insights.
E N D
FuseboxApplication Object Model Gabe Roffman, eTesters
Break Your Application Down • A quick way to simplify your application is to break it down • Break your massively complex site (“Home” application) into many sub-directories (“Circuit” applications)
Fusebox “Home” Application • This is your overall site. Such as: • www.etesters.com • www.fusebox.org • www.ebags.com • The Home application is more of a concept, it ties your circuit applications together
Connect the Circuits • How can I connect all my circuit applications together? • How can a team of developers connect their circuits together? • How can one company connect another company’s circuits together?
How EJBs do it • Java Beans are like circuit applications • Enterprise Java Beans are Beans that have standardized functions for communication
How Javascript does it • Uses Document Object Model • DOM is a structure of every element on the page • Using DHTML, you can change any value in the DOM
Javascript DOM Example: <html> <head> <title>Untitled</title> <script language="JavaScript"> // through the DOM, we can change the values of ‘myspan’ function change() { document.all.myspan.innerHTML = 'The text has changed'; } function changeback() { document.all.myspan.innerHTML = 'Now it has changed back!'; } </script> </head> <body> <span id="myspan“ onmouseover="change()" onmouseout="changeback()"> We'll change this text. </span> </body> </html>
Problems with the JS DOM • Different model in Netscape and Internet Explorer • No visible map of what the model is We can do better!
How would we do it? • Application object model • Similar to document object model in JS • Standardized structures for storing variables in the request scope • Stored in app_model for easy reference!
CF Structures • It is possible to achieve this same style of ‘dot’ notation in CF using structures • <cfset users=StructNew()> • <cfset users.user_132=StructNew()> • <cfset users.user_132.first_name=“Gabe”> Stop me if you do not understand structures
Request Variables • Request is a scope that is available both locally and within custom tags and even nested custom tags. • No need to use CFLOCK like with Application variables Stop me if you do not understand request variables
App_Model.cfm • A new application file is being introduced called “App_Model.cfm” • App_Model.cfm is for setting your AOM structures • Gives a clean map of your Global variables • Include app_model from within Application.cfm
Standard Global Variables • Which variables should we standardize on? • Can we categorize these standard variables? • What if I want to create my own?
Example App_Model.cfm <cfset request.page = StructNew()> <cfset request.page.js = StructNew()> <cfset request.page.js.scriptfiles = ArrayNew(1)> <cfset request.page.js.onLoad = ArrayNew(1)> <cfset request.page.js.onunLoad = ArrayNew(1)> <cfset request.page.display = true> <cfset request.page.title = "eTesters"> <cfset request.page.cssFiles = ArrayNew(1)> <cfset request.page.nocache = "true"> <cfset request.page.head = ""> <cfset request.page.HTML = ""> <cfset request.page.headers = ArrayNew(1)> <cfset request.page.body = StructNew()> <cfset request.page.footers = ArrayNew(1)> <cfset request.site = StructNew()> <cfset request.site.cfMapping = ""> <cfset request.site.section = ""> <cfset request.site.subsection = "">
Conclusion • The Application Object Model will assist tying many circuit applications together • More standardization makes for easier integration • Can have a forum at Fusebox.org to vote on components of the FOM