我在“冷聚8”上迈出了第一步。 我设计了一个部件/服务,有一台电灯。
在职能方面,我需要用错误和相应的错误信息再加2x2的表格。 错误信息是多语言的,储存在MySQL的表格中。
<<>Problem>:
我无法找到一种办法,在CFFunction tag中参考我的变量。 这并不可行:
// select from database
<cfparam name="Session.Sprache" default="DE">
<cfquery datasource="iln" name="texte">
SELECT *
FROM languages
WHERE sprache = "#Session.lang#"
</cfquery>
<cffunction name="createErrMsgsLog" returntype="object">
// create and populate
<cfset allErrMsgs=ArrayNew(2)>
<cfset allErrMsgs[1][1]="firma">
// not defined
<cfset allErrMsgs[1][2]="#tx_validate_firma#">
....
</cffunction>
Question:
How can I reference my variables aka #tx_validate_firma# correctly inside CFfunction. They are always undefined.
EDIT:
Ok. This seems to work:
Inside application.cfc 我叫:
<cfinvoke component="services.errorMsg"
method="createErrMsgsLog"
returnvariable="errMsgs">
</cfinvoke>
Inside errorMsg.cfc 我这样做了:
<cfcomponent displayname="errorMsg">
<cffunction name="createErrMsgsLog">
<cfquery datasource="mine" name="texte">
SELECT *
FROM sprachen
WHERE sprache = "#Session.Sprache#"
</cfquery>
<cfoutput query="texte">
// column name = value
<cfset "#trim(bezeichner)#" = "#trim(textinhalt)#">
</cfoutput>
// build array
<cfset allErrMsgs=ArrayNew(2)>
<cfset allErrMsgs[1][1] = "firma">
<cfset allErrMsgs[1][2] = #tx_validate_firma#>
...
<cfset errMsgs = serializeJSON(allErrMsgs)>
<cfreturn errMsgs>
</cffunction>
</cfcomponent>
这似乎像许多法典......。