• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

You have attempted to dereference a scalar variable of type class java.lang.String as a structure wi

New Here ,
Mar 25, 2010 Mar 25, 2010

Copy link to clipboard

Copied

You  have  attempted to dereference a scalar variable of type class  java.lang.String as a  structure with members

Hi

I receive the error in the title bar as a result of the following code but I can't see what I'm doing wrong:

<cfcomponent hint="sets background colour to help users see where they are during booking">

<cffunction name="cellcolour" returntype="struct">
<cfargument name="progressstage" type="string" required="true">
<cfset var stagecol="StructNew()">

<cfset oncolour="red">
<cfset offcolour="white">

<cfswitch expression="#progressstage#">
<cfcase value="progressstage1">
<cfset stagecol.colour1="#oncolour#">
<cfset stagecol.colour2="#offcolour#">
<cfset stagecol.colour3="#offcolour#">
<cfset stagecol.colour4="#offcolour#">
<cfset stagecol.colour5="#offcolour#">
</cfcase>

........... etc

Thew line where the error occurs is <cfset stagecol.colour1="#oncolour#">.

Thanks in advance for any advice

Dave

TOPICS
Getting started

Views

27.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2010 Mar 25, 2010

Copy link to clipboard

Copied

1. Are you using cftry/catch in our component? In some CF verison (at least), var scoped variables couldn't be referenced in cfcatch block.

2. What is your function returning? Is it a structure? Try removing the returntype attribute of the function.

3. Double check for overlapping variable names - try to change your variable names in the function and check if that helps.

And P.S. <cfset stagecol.colour1="#oncolour#"> is better and clearer written as <cfset stagecol.colour1 = oncolour>

Never use pound signs until you're outputting something, or dynamically evaluating a variable name.

-Fernis

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 25, 2010 Mar 25, 2010

Copy link to clipboard

Copied

<cfset var stagecol="StructNew()">

Look more closely at that line of code.

What's wrong with it?

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 25, 2010 Mar 25, 2010

Copy link to clipboard

Copied

<cfset var stagecol="StructNew()">

Those cannot be seen by the human eye!

...Which is exactly why the habit of using extra "#quotes#" is shooting oneself in the leg.

-Fernis

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2010 Mar 26, 2010

Copy link to clipboard

Copied

Thank you both so much for your help and "I promise I'll never do that again"........

Best wishes

Dave

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2010 Mar 26, 2010

Copy link to clipboard

Copied

LATEST

No worries mate.  We've all done it.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation