Element '' is undefined in a CFML structure referenced as part of an expression.

2,463 views
Skip to first unread message

MBakker

unread,
May 6, 2011, 6:47:54 AM5/6/11
to framework-one
Hi,

I keep getting errors like this when I request a page of my website:

Element '' is undefined in a CFML structure referenced as part of an
expression.

pointing to the followinfg a Srvice cfc:

<cfif
StructKeyExists(variables.language["#local.defaultLanguage#"],"#arguments.key#")>

When I do a reload=true I get the site allright. When I wait a while
and then click a link I get the error

Sessiontimeout = 20 minutes. I think when the session is expired, the
error occurs.

you can see the error on marcbakker.com.

FW/1 1.1.1 on CF9,0,1

Also: I'd like not the worls to see this error message. Rarther I'd
have a custom error page but <cfset variables.framework.error =
"page.error">
in Application.cfc has no effect (although the view exists)

What's the problem here and how can I solve it???

Marc

Eapen

unread,
May 6, 2011, 9:44:48 AM5/6/11
to framew...@googlegroups.com
If line 41 is:
<cfif StructKeyExists(variables.language["#local.defaultLanguage#"],"#arguments.key#")> 
then, the error might be because the variables.language['#local.defaultLanguage#'] doesn’t exist. So, maybe add a check before that to see if language['#local.defaultLanguage#'] exists in the variables scope.

If the error template throws an error (if it calls the same languageService.cfc), then it will show the detailed error message. If you dont want this detailed error message, you can override the error handler in framework.cfc with the following in Application.cfc:

<!--- overriding failure in framework.cfc --->

<cffunction name="failure" output="true">

<cfargument name="exception" default="">

<cfargument name="event" default="">

<cfif StructKeyExists(exception, "rootCause")>

<cfset exception = exception.rootCause>

</cfif>

<cfoutput><h1>A serious error occurred and an administrator has been notified.</h1></cfoutput>

<cfif StructKeyExists(request, "failedAction")>

<cfoutput><p>The action #request.failedAction# failed</p></cfoutput>

</cfif>

<cfmail to="EMAIL" from="EMAIL" subject="Error Details (#event#)" type="html">

    #CGI.REMOTE_ADDR# - #CGI.HTTP_USER_AGENT# - #CGI.PATH_INFO#?#CGI.QUERY_STRING#

    <cfdump var="#exception#">

    <cfdump var="#request#">

    <cfdump var="#session#">

    </cfmail>

   

<!---

<cfoutput><h2>#exception.message#</h2></cfoutput>

<cfoutput><p>#exception.detail# (#exception.type#)</p>

<cfdump var="#exception#">

--->

</cffunction>


- Eapen

MBakker

unread,
May 6, 2011, 12:34:50 PM5/6/11
to framework-one
ok, thanks. Didn't know about the failure() function...

I solved the error. "language" was not initialized because I put it in
the pseudo initialisator area - before the function call whre the
error occurred. I assumed it would be called before the function got
called. Not so, so I created an init() function and put the code in
there.

Marc

Eapen

unread,
May 6, 2011, 12:53:22 PM5/6/11
to framew...@googlegroups.com
Yep, even I discovered the failure() function after customers saw it although it is documented in the Wiki (but its not something you really pay attention to until you encounter it). 
Reply all
Reply to author
Forward
0 new messages