I'm working on an application built on Railo4 and am running into an interesting issue. I'm not doing anything new here as far as ColdFusion code goes. simply taking some strings, concatenating where needed, and returning a string.
<cffunction name="customBuildURL" access="public" returntype="string">
<cfargument name="subsystem" type="string" required="true" />
<cfargument name="section" type="string" required="true" />
<cfargument name="item" type="string" required="true" />
<cfargument name="args" type="string" required="true" />
<cfset var url = "index.cfm?action=" & ARGUMENTS.subsystem & ":" & ARGUMENTS.section />
<cfif Ucase(ARGUMENTS.item) NEQ "DEFAULT" >
<cfset url &= "." & ARGUMENTS.item />
</cfif>
<cfif ARGUMENTS.args NEQ "" >
<cfset url &= ARGUMENTS.args />
</cfif>
<cfreturn url />
</cffunction>
However, I'm getting two unusual errors.
1) The first is: Can't cast Complex Object Type Struct to String
and is being reported for the following two lines:
<cfset url &= "." & ARGUMENTS.item />
<cfset url &= ARGUMENTS.args />
2) The second is the function customBuildURL has an invalid return value , can't cast Object type [url] to a value of type [string]
upon return of the url
variable.
As you can see, I'm not doing anything elaborate here. Just setting some strings, concatenating them and then returning it. I don't see where an 'Object' is being created and being cast as a string. I double checked the use of the &=
operator and that doesn't appear to be the issue because if I do a url = url & "." & ARGUMENTS.item
the same error is reported.
Any ideas?
Url
is a reserved word in ColdFusion, so even though you're var-ing it in the function it's still picking up the actual structure of url variables.
Here's a complete list of reserved words in ColdFusion