Highlighted

GetMetaData Returns phantom Parameters

Engaged ,
Jun 20, 2016

Copy link to clipboard

Copied

I'm playing around with GetMetaData to do a little introspection of my CFC's when I ran into an anomaly I don't understand.

My CFC has multiple functions embedded within it.  One of these functions is defined as follows:

<cffunction name="getMyDenied" access="public" returntype="query">

  <cfargument name="userid" type="string" required="yes">

  <cfargument name="environment" type="string" required="no" default="0" hint="Pass in 0 for Development and 1 for Production">

...

</CFFUNCTION>

When I exam the CFC using GetMetaData I get this output for the getMyDenied function:

getMyDenied.JPG

The thing that confuses me is why the HINT parameter is showing up in the userid argument. 

The weird thing about this is if I exam the HINT parameter using #Len(TRIM(CFC_Functions.functions[cc].Parameters[1].Hint))# I get the number 6. If I copy the value into a new array or structure and then CFDUMP the results it shows up as an "Empty String".

Then in the same CFC I also have this function:

<cffunction name="getMyPurchaseOrders" access="public" returntype="query">

  <cfargument name="userid" type="numeric" required="yes">

  <cfargument name="environment" type="string" required="no" default="0" hint="Pass in 0 for Development and 1 for Production">

  ...

</CFFUNCTION>

When I exam the CFC using GetMetaData I get this output for the getMyPurchaseOrders function:

getMyPurchaseOrders.JPG

So my two questions are:

  1. Why does the getMyPurchaseOrders function return properly where as the getMyDenied function returns a phantom HINT parameter?
  2. How do I trap the phantom HINT parameter?  What I can tell is:
    • if I run IsValid('String',CFC_Functions.functions[cc].Parameters[xx].Hint) against the variable the return is TRUE. 
    • <CFSET z = ToString(CFC_Functions.functions[cc].Parameters[xx].Hint)> #Len(TRIM(z))#  returns 6.
    • <CFIF CFC_Functions.functions[cc].Parameters[xx].Hint EQ '      '>WTF<CFELSE>Nada</CFIF> always returns Nada even though I entered 6 spaces in the EQ clause.

Any thoughts or suggestions are welcome!!!

@BKBK, I'm using CF Server 9,0,0,251028.  I expected to see something similar to what you displayed too, which is why I was confused.

Still not sure why the GetMetaData call is returning the phantom parameter but I finally figured out what the returned value was!  Of course once the light came on I felt a little like a dumba$$.  😮

Question: What takes 6 characters to display a blank space? Answer: "& nbsp ;"  (without the spaces so it will display in this form) of course.  Once I built my trap to look for those 6 characters I was able to programmatically deal with the phantom parameter.

Views

204

Likes

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

GetMetaData Returns phantom Parameters

Engaged ,
Jun 20, 2016

Copy link to clipboard

Copied

I'm playing around with GetMetaData to do a little introspection of my CFC's when I ran into an anomaly I don't understand.

My CFC has multiple functions embedded within it.  One of these functions is defined as follows:

<cffunction name="getMyDenied" access="public" returntype="query">

  <cfargument name="userid" type="string" required="yes">

  <cfargument name="environment" type="string" required="no" default="0" hint="Pass in 0 for Development and 1 for Production">

...

</CFFUNCTION>

When I exam the CFC using GetMetaData I get this output for the getMyDenied function:

getMyDenied.JPG

The thing that confuses me is why the HINT parameter is showing up in the userid argument. 

The weird thing about this is if I exam the HINT parameter using #Len(TRIM(CFC_Functions.functions[cc].Parameters[1].Hint))# I get the number 6. If I copy the value into a new array or structure and then CFDUMP the results it shows up as an "Empty String".

Then in the same CFC I also have this function:

<cffunction name="getMyPurchaseOrders" access="public" returntype="query">

  <cfargument name="userid" type="numeric" required="yes">

  <cfargument name="environment" type="string" required="no" default="0" hint="Pass in 0 for Development and 1 for Production">

  ...

</CFFUNCTION>

When I exam the CFC using GetMetaData I get this output for the getMyPurchaseOrders function:

getMyPurchaseOrders.JPG

So my two questions are:

  1. Why does the getMyPurchaseOrders function return properly where as the getMyDenied function returns a phantom HINT parameter?
  2. How do I trap the phantom HINT parameter?  What I can tell is:
    • if I run IsValid('String',CFC_Functions.functions[cc].Parameters[xx].Hint) against the variable the return is TRUE. 
    • <CFSET z = ToString(CFC_Functions.functions[cc].Parameters[xx].Hint)> #Len(TRIM(z))#  returns 6.
    • <CFIF CFC_Functions.functions[cc].Parameters[xx].Hint EQ '      '>WTF<CFELSE>Nada</CFIF> always returns Nada even though I entered 6 spaces in the EQ clause.

Any thoughts or suggestions are welcome!!!

@BKBK, I'm using CF Server 9,0,0,251028.  I expected to see something similar to what you displayed too, which is why I was confused.

Still not sure why the GetMetaData call is returning the phantom parameter but I finally figured out what the returned value was!  Of course once the light came on I felt a little like a dumba$$.  😮

Question: What takes 6 characters to display a blank space? Answer: "& nbsp ;"  (without the spaces so it will display in this form) of course.  Once I built my trap to look for those 6 characters I was able to programmatically deal with the phantom parameter.

Views

205

Likes

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
Jun 20, 2016 0
Adobe Community Professional ,
Jun 20, 2016

Copy link to clipboard

Copied

Weird. What is your ColdFusion version? How do you display the metadata?

I am on Coldfusion 2016. I wrote a CFC based on your 2 functions, and called it test.cfc. Then I ran this code in a page on the same directory:

<cfset obj=createobject("component","test")>

<cfdump var="#getMetadata(obj).functions#">

The result is as expected.

Likes

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
Reply
Loading...
Jun 20, 2016 0
Engaged ,
Jun 20, 2016

Copy link to clipboard

Copied

@BKBK, I'm using CF Server 9,0,0,251028.  I expected to see something similar to what you displayed too, which is why I was confused.

Still not sure why the GetMetaData call is returning the phantom parameter but I finally figured out what the returned value was!  Of course once the light came on I felt a little like a dumba$$.  😮

Question: What takes 6 characters to display a blank space? Answer: "& nbsp ;"  (without the spaces so it will display in this form) of course.  Once I built my trap to look for those 6 characters I was able to programmatically deal with the phantom parameter.

Likes

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
Reply
Loading...
Jun 20, 2016 1