Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8285041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:19:48+00:00 2026-06-08T11:19:48+00:00

I’m having a multi-language site and need to pass error messages in different languages

  • 0

I’m having a multi-language site and need to pass error messages in different languages to the browser for client-side form validation.

Right now I’m using a error.cfc, which contains:

 <cfcomponent displayname="errorMsg" hint="create error msgs">  
      <cffunction name="createErrMsgsLog" output="false" returntype="string">               

           <cfset var allErrMsgs=ArrayNew(2)>
           <cfquery datasource="db" name="texte" cachedWithin="#Session.globalCache#">
                ... query db for snippets and text blocks ...
           </cfquery>
           <cfoutput query="texte"><cfset "#trim(snippet)#" = "#trim(text)#"></cfoutput>
           <cfscript>
                allErrMsgs[1][1] = "comp";
                allErrMsgs[1][2] = tx_validate_comp;
                ...
           </cfscript>
           <cfset Session.errMsgs = serializeJSON(allErrMsgs)>
           <cfreturn Session.errMsgs> 
      </cffunction>
 </cfcomponent> 

So I’m grabbing all texts, fill an array, which is serialized and returned as a string.

The cfc is called inside application.cfc

 <cffunction name="onSessionStart" returnType="boolean" output="false" hint="session initalizer">
      ...
      <cfinvoke component="services.errorMsg" method="createErrMsgsLog" returnvariable="errMsgs"></cfinvoke>
      <cfset Session.errMsgs = errMsgs>
      ...
 </cffunction>

And on every page I’m including it like this:

 <script type="text/javascript" language="JavaScript">var #toScript(Session.errMsgs, "errorLog")#</script>

I’m not sure why I’m ending up with errorLog is undefined sometimes, but it happens occassionaly when I’m refreshing a page or when I enter a page URL manually inside my application (go from page ABC to page DEF).

I’m using Jquery Mobile, so when the Session inits and the first page loads, the errorLog is rendered once into the first page. Since all subsequent pages are pulled in/removed from this page, the initial errorLog is always active. I guess when manually changing the URL, I’m loosing the first page errorLog, because I’m loading a new page, but I don’t understand why the new page does not get “it’s own” errorLog or why it’s undefined all of a sudden.

Question:
Any idea how I can make sure errorLog is defined = how can I ensure the errorMessages gets created in Coldfusion?

Thanks for help!

EDIT:
Ok. I have added a check in Coldfusion, so in case the Session variables is undefined, I’m recreating it. So far however, it is always there. It seems to only happen when I manually change the URL and go to another page. I can reproduce in IE8. Strangely, when I check the IE8 debugger, errorLog is there, but I’m still getting an error telling me it’s undefined…

EDIT:
I have moved the cfinvoke to on request handler inside the application.cfc.

    <cfif len( Session.errMsgs ) EQ 0>
        <cfinvoke component="services.errorMsg" method="createErrMsgsLog" returnvariable="errMsgs"></cfinvoke>
        <cfset Session.errMsgs = errMsgs> 
    </cfif> 

The Coldfusion part seems to work correctly, because I’m only ending up inside the if-statement when the application fires up. Afterwards errMsgs are defined, but the problem remains… Frustrating.

EDIT:
Another cause could be my JSON string. I’m setting it like this:

 <script type="text/javascript">var #toScript(Session.errMsgs, "errorLog")#; alert(errorLog);</script>

The alert alerts it allright, but if I try to grab it later on like so:

 err = jQuery.parseJSON(errorLog);

I’m getting NULL. My JSON looks like this (valid, alerting Session.errMsgs)

 [["firma","Bitte Firmennamen eingeben!"],["firma_re","Bitte Firmennamen eingeben!"],... 

or this (invalid, outputting with toScript):

 "[[\"firma\",\"Bitte Firmennamen eingeben!\"],[\"firma_re\",\.... (invalid)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:19:50+00:00Added an answer on June 8, 2026 at 11:19 am

    I think I found the issue. I’m using RequireJS and I had the call to initiliaze requireJS above the snippet, which entered the variable onto the page. While this seems to work on the first page, on subsequent page, requireJS seems much faster in re-parsing js files, so the file looking for errorLog was parsed before the variable was set on the page. Moving requireJS init to after setting errorLog seems to solve the problem…. some search…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.