Changes between Version 9 and Version 10 of QuickStart/3:BuildingaForm
- Timestamp:
- 12/31/09 02:11:20 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
QuickStart/3:BuildingaForm
v9 v10 11 11 12 12 {{{ 13 <cfset submit = event.linkTo( event.getValue("xe_translate") ) /> 13 14 <cfset event.copyToScope( variables, "xe_translate" ) /> 15 <cfset submit = event.linkTo( xe_translate ) /> 14 16 15 17 <cfform action="#submit#"> … … 17 19 <input type="submit" value="Ok" /> 18 20 </cfform> 21 19 22 }}} 20 23 … … 28 31 The event object contains data like a query from a database or (big surprise) the translated version of the phrase that we're asking the user to enter. 29 32 30 To get to one of the variables, you ask the event object to "get its value" with the getValue() function.33 To get to the event variables, you can ask the event object to copy them into the scope of your choice, typically the variables scope, with the copyToScope() function. You can also retrieve individual values (variables) from the event object by using the getValue() function, but unless you only need a single value, using copyToScope() will save you a lot of repetitive typing. 31 34 32 There are a few "default" variables added to event object you need to be aware of: 35 Also note the use of the linkTo() function. This is another convenience method of the event object that will create a link from a supplied event name, so calling event.linkTo( "myevent" ) will produce "index.cfm?event=myevent". If any Model-Glue configuration settings are changed at some point in the future (for example, changing "event" to "e", "index.cfm" to "page.cfm", or enabling SES URLs), the generated links will automatically change to use the new conventions. 33 36 34 * "myself" is the URL of the current page with "?event=" added to it, such as "index.cfm?event=" 35 * "self" is the URL of the current page without the "?event=" bit, such as "index.cfm" 36 * "event" is the name of the current event. Don't worry about this one. 37 * "eventValue" is the name of the URL variable that contains the current event. Don't worry about this one much, either. 38 39 Therefore, the first line in that frmPhrase.cfm says "make me a link please, and use the value in the event object for 'xe_translate' as the name of the event." 37 Therefore, the first two lines in that frmPhrase.cfm say "make me a link please, using the value in the event object for 'xe_translate' as the name of the event." 40 38 41 39 So what's with this "xe_translate" value? "XE" stands for "eXit Event," and has emerged as a best practice in Model-Glue applications (because it's taken from a best practice in Fusebox!). It lets us reuse this view in multiple places because we determine the action page of the form at runtime, instead of hard coding it into our .CFM template. 42 40 43 So where does the value of xe_translate come from? It's time to learn a bit of Model-Glue XML. (Don't worry! I just wrote the entire tag reference, and it's only sixteen tags! And about five of them are just placeholders that contain other tags!)41 So where does the value of xe_translate come from? It's time to learn a bit of Model-Glue XML. 44 42 45 43 To create the actual event handler to display the form, do the following:
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)