2011-06-15 42 views
1

我读过许多有onSessionEnd问题的人的帖子。这是我第一次将application.cfm转换为application.cfc,并且onSessionEnd与我尝试调用的CFFunction不起作用。ColdFusion onSessionEnd问题

我猜这是怎么挂起来的是如何从它所在的/ lib/components /文件夹中正确调用该组件。

当用户登录时,我创建了一个会话数组,用于跟踪该作业中的jobNumber和last_completed_step。用户会话中有多个作业。在会议结束时,我想将更新后的阵列数据写回数据库。

我应该说清楚,目前我查看我的日志文件,看到会话已启动 - 如下面所示的onSessionStart中编码。此外,onSessionEnd还会在取出组件的调用时写入日志文件。换句话说,如果我只是把它写成“会话结束”。到日志文件,我会在日志文件中看到它。我在CF管理员和我的app.cfc中设置了当前会话超时3分钟进行测试。

如果我从单独的文件(也是在根级别)调用jobState.cfc中的“giveMeAnswer”方法,giveMeAnswer方法将正常工作并返回值“我是CFC”。

如果我将jobState.cfc移动到根级别并将组件属性设置为“jobState”,我也从组件返回。

<!--- Runs when your session starts ---> 
<cffunction name="onSessionStart" returnType="void" output="false"> 

<!--- :: invoke all session variables | moved out of on session start :: ---> 
<cfinvoke component="#application.virtualPaths.cfcPath#system/sessionVars" method="init" /> 

<cflog file="#This.Name#" type="Information" text="Session started."> 

</cffunction> 

<!--- Runs when session times out ---> 

<cffunction name="onSessionEnd" returntype="void"> 
<cfargument name="SessionScope" type="struct" required="true" /> 
<cfargument name="ApplicationScope" type="struct" required="true" /> 

<cfinvoke component="/lib/components/jobState" method="giveMeAnswer" returnvariable="returnFromCfc"> 
</cfinvoke> 

<cflog file="#This.Name#" type="Information" text="Session ended. #returnFromCfc#"> 

<cfreturn /> 
</cffunction> 

那么,它只是没有找到组件?任何其他想法?

谢谢了,杰里

回答

3

我知道我已经看到人们在使用前/中组件的调用,但我不相信这是官方支持。你想用一个点符号路径,而不是阿拉

成分=“lib.components.jobstate”

,并确保LIB要么是子目录或指向lib文件夹已知CF映射。