2

I have the line:

<cfif isArray( this.filters[this.name] ) 
       AND this.filters[this.name].Contains(JavaCast("string",par.fval)) >

which is generating an 'Invalid CFML Construct: contains' error message.

Am I missing something or are the java methods not available when an array is created?

3
  • Just curious.. is ArrayFind/ArrayFindNoCase not available in your version? Commented Jul 2, 2013 at 16:03
  • Hi Leigh, it is available but I didnt realize until a little later that function existed and in the meantime I already got zealous on using the contains method. Commented Jul 2, 2013 at 17:24
  • Well just watch out for data type differences. In case you are not already aware, contains() makes a distinction on data type (unlike CF array functions). Searching for "1.5" (string) will not yield the same results as val(1.5) (number) Commented Jul 2, 2013 at 17:30

1 Answer 1

4

For me the error is a little more explicit:

Invalid CFML construct found on line 1 at column 71.

ColdFusion was looking at the following text:
Contains

And it's saying that because contains is a reserved-ish word in CFML, and something about the combo of that and the square brackets is fooling the parser into thinking there's a problem.

However this sort of thing should work:

<cfset proxy = this.filters[this.name]>
<cfif isArray( this.filters[this.name] )  AND proxy.Contains(JavaCast("string",par.fval)) >
</cfif>

NB: this is a vagary of ColdFusion... Railo does not have this problem. I'm gonna blog it & cross-reference here.

Sign up to request clarification or add additional context in comments.

2 Comments

lol I really should have thrown more syntax at it. Keeping everything dynamic Im always running into this kind of stuff. This is good to know for the future. Thank you very much.
Just ran into this exact situation today... wish I would have seen this sooner!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.