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

Problem with Java functions within a CFC

Engaged ,
Nov 30, 2008 Nov 30, 2008
Hi,

I looked on CFLIB for a function that would return the current URL. I found a really neat one which doesn't use the sometimes unreliable cgi variables.

It goes something like this:

<cffunction name="getCurrentURL" hint="Gets the current URL" returntype="string" output="false" access="public">

<cfset var currentURL = getPageContext().getRequest().GetRequestUrl().toString() />

<cfif len(trim(cgi.query_string))>
<cfset currentURL = currentURL & "?" & cgi.query_string />
</cfif>

<cfreturn currentURL />

</cffunction>

If I call this on like a top level index.cfm it works perfectly...however, if I put this function into a CFC, I get an odd string returned looking something like:

cfutils2ecfc1871686742$funcGETCURRENTURL@666b79

There's no error, but the string it sends back is clearly very odd.

Is there a way to use this function within a CFC? I figured it made sense as I would be using something like this quite a lot and don't want to repeat myself.

Many thanks,
Mikey.
269
Translate
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 ,
Nov 30, 2008 Nov 30, 2008
LATEST
a request to a .cfc is a separate request, and thus has its own
PageContext, which is not same as PageContext of requesting template...

and what's so unreliable about cgi.script_name???

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
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