Changes between Version 9 and Version 10 of QuickStart/4:HandlingaForm

Show
Ignore:
Timestamp:
12/21/09 21:08:10 (16 years ago)
Author:
cfgrok (IP: 64.30.223.5)
Comment:

Updates to Quickstart Section

Legend:

Unmodified
Added
Removed
Modified
  • QuickStart/4:HandlingaForm

    v9 v10  
    3939 
    4040{{{ 
    41 <controller name="MyController" type="translator.controller.Controller"> 
    42     <message-listener message="OnRequestStart" /> 
    43     <message-listener message="OnRequestEnd" /> 
     41<controller name="Controller" type="translator.controller.Controller"> 
    4442    <message-listener message="NeedTranslation" function="TranslatePhrase" /> 
    4543</controller> 
     
    4846(Note: If you do specify a function attribute, when the message is broadcast, it will call that specific function on the controller. If you do not specify a function attribute, Model-Glue will call a function named the same as the value of the message attribute.) 
    4947 
    50 Ok, now try the form. Again. 
     48OK, now try the form. Again. 
    5149 
    52 Still nothing? There's one last piece to the puzzle: write a !TranslatePhrase function in the Controller that asks our Model to translate a phrase! That's easy enough - just open /translator/controller/Controller.cfc and add the following <cffunction>: 
     50This time you will encounter an error: "The method !TranslatePhrase was not found in component [your file system path]Controller.cfc" 
     51 
     52There's one last piece to the puzzle: write a !TranslatePhrase function in the Controller that asks our Model to translate a phrase! That's easy enough - just open /translator/controller/Controller.cfc and add the following <cffunction>: 
    5353 
    5454{{{ 
     
    6060    <cfset var result = translator.translate(phrase) /> 
    6161 
    62     <cfset arguments.event.addTraceStatement("TranslatePhrase Results", result) /> 
     62    <cfset arguments.event.addTraceStatement("User", "TranslatePhrase Results", result) /> 
    6363    <cfset arguments.event.setValue("translatedPhrase", result) /> 
    6464</cffunction> 
    65  
    66 <cffunction name="OnRequestStart" access="public" returntype="void" output="false"></cffunction> 
    67  
    68 <cffunction name="OnRequestEnd" access="public" returntype="void" output="false"></cffunction> 
    69  
    7065}}} 
    7166 
    72 (Note: that in prior versions of the framework, the addTraceStatement() function was named trace(), but this was changed in order to support !ColdFusion 9, which was added a native trace() function to CFML.) 
     67(Note: that in prior versions of the framework, the addTraceStatement() function was named trace(), but this was changed in order to support !ColdFusion 9, which added a native trace() function to CFML.) 
    7368 
    7469So what does all that do? 
     
    9792 
    9893{{{ 
    99 <cfset arguments.event.addTraceStatement("TranslatePhrase Results", result) /> 
     94<cfset arguments.event.addTraceStatement("User", "TranslatePhrase Results", result) /> 
    10095}}} 
    10196 
     
    106101}}} 
    107102 
    108 Ok, finally, run the form! Seriously, something will happen this time! You won't get much, but you'll see a line in the Model-Glue debugging trace labelled "!TranslatePhrase Results" that shows the translated phrase. 
     103OK, finally, run the form! Seriously, something will happen this time! You won't get much, but you'll see a row in the Model-Glue debugging trace with the message "!TranslatePhrase Results" that shows the translated phrase. 
    109104 
    110105As a last step, let's add a view that shows our translated phrase. That'd probably make users happy, because we'll turn the debugging trace off when we deploy this application. 
     
    113108 
    114109{{{ 
    115 <cfset translationForm = event.linkTo( event.getValue("xe.translationForm"), "phrase" ) /> 
     110<cfset translationForm = event.linkTo( event.getValue("xe_translationForm"), "phrase" ) /> 
    116111<cfset translatedPhrase = event.getValue("translatedPhrase") /> 
    117112 
     
    131126    <views> 
    132127        <include name="body" template="dspPhrase.cfm"> 
    133             <value name="xe.translationForm" value="translationForm" /> 
     128            <value name="xe_translationForm" value="translationForm" /> 
    134129        </include> 
    135130    </views> 
     
    141136---- 
    142137 
    143 Back [wiki:QuickStart/3:BuildingaForm#Quickstart3:BuildingaFormEvent Quickstart 3: Building a Form Event] 
     138Back [wiki:QuickStart/3:BuildingaForm Quickstart 3: Building a Form Event] 
    144139 
    145 Next [wiki:QuickStart/5:ValidatingaForm#Quickstart5:ValidatingaForm Quickstart 5: Validating a Form] 
     140Next [wiki:QuickStart/5:ValidatingaForm Quickstart 5: Validating a Form] 
    146141