Can anyone tell me what the problem is? I tried to run some .cfm files but it does not trigger any effect of cffunction except cfcomponent? Am I missing something? Can anyone explain to me?
<cfcomponent>
<cfset THIS.Name = "formdemo">
<cfset THIS.SessionManagement = true>
<cfset This.Sessiontimeout="#createtimespan(0,0,20,0)#">
<cfset This.applicationtimeout="#createtimespan(5,0,0,0)#">
--Entered cfcomponent--
<cffunction name="onApplicationStart" returnType="boolean" output="false">
--Entered Application Start--
<cfset application.portfolioUploadRoot = "ram:///portfoliouploads">
<cfif not directoryExists(application.portfolioUploadRoot)>
<cfdirectory action="create" directory="#application.portfolioUploadRoot#">
</cfif>
<cfreturn true>
</cffunction>
<cffunction name="onSessionStart" returnType="void" output="false">
--Entered Session Start--
<cfset session.myuploadroot = application.portfolioUploadRoot & "/" & replace(createUUID(), "-", "_", "all")>
<cfif not directoryExists(session.myuploadroot)>
<cfdirectory action="create" directory="#session.myuploadroot#">
</cfif>
</cffunction>
<cffunction name="onApplicationEnd" returnType="void" output="false">
--Entered Application End--
<cfargument name="applicationScope" required="true">
<cfif directoryExists(arguments.applicationScope.portfolioUploadRoot)>
<cfdirectory action="delete" recurse="true" directory="#arguments.applicationScope.portfolioUploadRoot#">
</cfif>
</cffunction>
<cffunction name="onSessionEnd" returnType="void" output="false">
--Entered Session End--
<cfargument name="sessionScope" type="struct" required="true">
<cfargument name="appScope" type="struct" required="false">
<cfif directoryExists(arguments.sessionScope.myuploadroot)>
<cfdirectory action="delete" recurse="true" directory="#arguments.sessionScope.myuploadroot#">
</cfif>
</cffunction>
</cfcomponent>
The result only shows "--Entered cfcomponent--" on the beginning of cfmpage.cfm.
cfmpage.cfm:
<cfparam name="form.textname" default="">
<cfparam name="form.textemail" default="">
<cfparam name="form.docattach" default="">
<cfif structKeyExists(form, "Submit")>
<cfset form.textname = trim(htmlEditFormat(form.textname))>
<cfset form.textemail = trim(htmlEditFormat(form.textemail))>
<cflocation url="formcomplete.cfm" addToken="false">
</cfif>
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<form method="post" enctype="multipart/form-data">
<cfoutput>
<input id="textname" name="textname" type="text" class="input-large" required="" value="#form.textname#">
<input id="textemail" name="textemail" type="text" class="input-large" required="" value="#form.textemail#">
</cfoutput>
</form>
</body>
</html>
It is doing as it should.
Neither of the latter two will ever show any text on screen because you can't see that event while visiting the page. You can however call them manually to trigger their effects. You can, however, log these actions however you choose. You may use cflog, for instance, in this fashion:
In other words:
Will display the text because it is firing the event.
Finally, if you're wanting something to happen on each page, onRequestStart and onRequestEnd or onRequest are great options. OnRequest is a method that wraps around the page, so you can do header and footer actions in the same request, but you must explicitly include the file, wheras onRequestStart / onRequestEnd execute at the start and end of the request.
The order of action methods invoked is
Lastly, functions don't fire unless they're called. This applies to functions you write yourself as well.
Won't do anything until you actually try something like
<cfoutput>#foo()#</cfoutput>
.In the case of "default functions", these are just special functions/methods that CF calls at certain points if they're present.