Changes between Version 7 and Version 8 of QuickStart/3:BuildingaForm
- Timestamp:
- 12/21/09 20:49:46 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
QuickStart/3:BuildingaForm
v7 v8 11 11 12 12 {{{ 13 <cfset submit = event.linkTo( event.getValue("xe .translate") ) />13 <cfset submit = event.linkTo( event.getValue("xe_translate") ) /> 14 14 15 15 <cfform action="#submit#"> … … 19 19 }}} 20 20 21 O k- what's with this "event" stuff?21 OK - what's with this "event" stuff? 22 22 23 Whenever you're writing a .CFM view, there are two variables always available: "event" and "viewcollection." We'll get to viewcollection in a bit, but here's the rundown on event: 24 Event:: 25 An event object contains all the variables FORM and URL scopes as well as any other values added by the framework. 23 Whenever you're writing a .CFM view, there are two variables always available: "event" and "viewcollection". We'll get to viewcollection in a bit, but here's the rundown on event: 24 25 Event: 26 An event object contains all the variables in the FORM and URL scopes as well as any other values added by the framework. 27 26 28 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. 27 29 … … 35 37 * "eventValue" is the name of the URL variable that contains the current event. Don't worry about this one much, either. 36 38 37 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."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." 38 40 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.41 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. 40 42 41 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!)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!) 42 44 43 45 To create the actual event handler to display the form, do the following: … … 70 72 }}} 71 73 72 Now, we need to provide the value for "xe .translate." We do this with the (very aptly named!) <value> tag:74 Now, we need to provide the value for "xe_translate." We do this with the (very aptly named!) <value> tag: 73 75 74 76 {{{ … … 77 79 <views> 78 80 <include name="body" template="frmPhrase.cfm"> 79 <value name="xe .translate" value="translationFormAction" />81 <value name="xe_translate" value="translationFormAction" /> 80 82 </include> 81 83 </views> … … 86 88 }}} 87 89 88 Finally, run the page by visiting http://localhost/translator/index.cfm?event=translationForm . You should see your form. Viewing its source, you'll see that its action page is index.cfm?event=translationFormAction.90 Finally, run the page by visiting http://localhost/translator/index.cfm?event=translationForm. You should see your form. Viewing its source, you'll see that its action page is index.cfm?event=translationFormAction. 89 91 90 92 You've just learned about a quarter of the Model-Glue framework. Not too bad, eh? 93 91 94 ---- 92 95 93 Back [wiki:QuickStart/2:ModellingourApplication #Quickstart2:ModelingourApplicationQuickstart 2: Modeling our Application]96 Back [wiki:QuickStart/2:ModellingourApplication Quickstart 2: Modeling our Application] 94 97 95 Next [wiki:QuickStart/4:HandlingaForm #Quickstart4:HandlingaFormQuickstart 4: Handling a Form]98 Next [wiki:QuickStart/4:HandlingaForm Quickstart 4: Handling a Form] 96 99
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)