Submit Your Article
Home Articles News Tutorials Videos Add An Article
Topics: Design Photoshop Programming PHP CSS Java Database Web Development Javascript Ajax
– Close + Open

Find Out More About DevWebPro!

Sign up for the newsletter


» Terms & Conditions

Welcome to the New DevWebPro!

DevWebPro Includes:
  Hundreds Of Tutorials   Developer News
  Unique Gadget Videos   Tons of Topics to Discuss
  Expert Advice   We Will Publish Your Articles

Model-Glue & URL Consistency

By: Sean Corfield
Tuesday, November 20th, 2007
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook

Someone asked on the Model-Glue mailing list how to keep deal with keeping event handler names and URLs in views consistent, i.e., if they change an event handler name, how can they avoid having to change the string wherever it appears in links in their views.

Fusebox has long had a convention to deal with this known as XFAs – eXit FuseActions. The idea is to abstract the actual fuseaction name into a variable.

You specify all the exit points for a view as XFAs in the XML and refer to the variable in the view instead of hard-coding the fuseaction name. If you need to change the control flow – or the fuseaction name – you just change the XFA in the XML file and your views all pick that up.

Often Fuseboxers set common XFA values in the prefuseaction for the circuit or the global preprocess fuseaction for the application, making it very simple to manage exit points.

You can do something similar in Model-Glue by using the value tag on an include:

<include template=”myView.cfm”>
<value name=”xe.home” value=”welcome”>
</value>
</include>

Your view can refer to the exit point as a variable when building the URL like this:

some link text

Note that Model-Glue creates the myself event value automatically from the defaultTemplate and eventValue settings in the section of your ModelGlue.xml file.

This abstracts even the file name and event key out of your views and is good practice.

Again, something borrowed from Fusebox conventions (although Fusebox does not do this automatically – it’s just a common convention).

If you want to set exit points globally in Model-Glue, you could make them settings in the section and then have a listener for onQueueComplete which pulled all xe.* settings and added them to the event (view state).

Topics: , ,

About the Author:
Sean is currently Chief Technology Officer for Railo Technologies US. He has worked in IT for over twenty five years, starting out writing database systems and compilers then moving into mobile telecoms and finally into web development in 1997. Along the way, he worked on the ISO and ANSI C++ Standards committees for eight years and is a staunch advocate of software standards and best practice. Sean has championed and contributed to a number of CFML frameworks and was lead developer on Fusebox for two years.
DevWebPro is an iEntry Network ® publication - © 1998-2010 All Rights Reserved