Aug
17
2007
Model Glue Tips Part 7: Set myself in your views
Posted by Mark Drew at 6:54 AM
5 comments - Categories:
model-glue
<a href="#CGI.SCRIPT_NAME#?event=my.event">My Event </a>
But what happens if you change the event key to something else (you can do that in the ModelGlue configuration section in the ColdSpring.xml file, see the property for "eventValue") such as "go" or "action"? You would have to change every view.
A simple way round this is to put at the top of each view the following:
<cfset myself = ViewState.getValue('myself')>
And then change your links to:
<a href="#myself#my.event">My Event </a>
What do you think?

Raymond Camden wrote on 09/22/08 11:13 AM
Yep, this is a good tip. This is two good tips actually. So first, youare right in using the myself VS value to be more 'safe' in the MG framework. The second tip - copying it from the VS into a local var, is also a good one as it saves you a heck of a lot of typing.