PageRenderTime 470ms CodeModel.GetById 437ms app.highlight 1ms RepoModel.GetById 30ms app.codeStats 0ms

/SampleApplication/ColdBox3/handlers/enquiry.cfc

http://github.com/bobsilverberg/ValidateThisColdBoxPlugin
ColdFusion CFScript | 59 lines | 42 code | 14 blank | 3 comment | 1 complexity | 796bb7019e819fb50995da425f5cad3f MD5 | raw file
 1<cfcomponent extends="model.abstract.AbstractHandler" hint="the enquiry handler">
 2
 3	<!---
 4	-------------------------------------------------------------------------
 5	dependancy injection
 6	-------------------------------------------------------------------------
 7	--->
 8	<cfproperty name="FormService" type="model:FormService" scope="instance">
 9	
10	<!---
11	-------------------------------------------------------------------------
12	public handlers
13	-------------------------------------------------------------------------
14	--->
15	
16
17	<cffunction name="index" returntype="void" output="false" hint="I am the default event">
18		<cfargument name="event" required="true">
19		<cfscript>
20		var rc = arguments.Event.getCollection();
21
22		rc.Enquiry = instance.FormService.newEnquiry();
23		
24		// need an empty validation result object for display
25		rc.ValidationResult = instance.FormService.newValidationResult();
26		
27		// get required fields
28		rc.RequiredFields = instance.FormService.getEnquiryRequiredFields();
29		
30		// set view
31		arguments.Event.setView( "enquiry/index" );
32		</cfscript>
33	</cffunction>
34
35	<cffunction name="send" returntype="void" output="false" hint="I send an enquiry">
36		<cfargument name="event" required="true">
37		<cfscript>
38
39		var rc = arguments.Event.getCollection();
40
41		var SendResult = instance.FormService.sendEnquiry( rc );
42		
43		if ( SendResult.getIsSuccess() )
44		{
45			flash.put( "message", "Enquiry sent" );
46			setNextEvent( "enquiry.index" );
47		}
48		else
49		{
50			rc.ValidationResult = SendResult;
51			rc.Enquiry = rc.ValidationResult.getTheObject();
52			rc.RequiredFields = instance.FormService.getEnquiryRequiredFields();
53			
54			arguments.Event.setView( "enquiry/index" );
55		}
56		</cfscript>
57	</cffunction>
58
59</cfcomponent>