<CFFUNCTION> Tag - ColdFusion


>> Return to ColdFusion Tag Index

The <CFFUNCTION> tag allows you ...



  <CFFUNCTION> Comments from Macromedia LiveDocsLiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
If you are returning a string with the cffunction, make sure to set the output to false or characters will be added to the beginning of the string. http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=3&threadid=952492&highlight_key=y&keyword1=cffunction

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
FYI, a developer has reported that he had a problem using cfinvoke to
call a web service with multiple arguments, but was able to solve it
by using cfscript instead.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Has any one noticed that if there is any character between CFOUTPUT or a line return and CFFUNCTION call an extra white space is added to the left of the CFRETURN value? If I set the return value to another variable, I get the output I expect. This is what I get when I run the code below. Anyone know why this is? I can find any documentation on this affect.

Some text here: THE TEST STRING
THE TEST STRING
Some text here:THE TEST STRING

<cffunction name="myFunction" returntype="string">
<cfargument name="myFunctionString" type="string" required="yes">
<cfset whatItDoes = UCase(myFunctionString)>
<cfreturn whatItDoes>
</cffunction>

<cfset temp = myFunction('the test string')>

<cfoutput>
Some text here:#myFunction('the test string')#

#myFunction('the test string')#

Some text here:#temp#

</cfoutput>

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
To return a component from cffunction, use the dot notation "folder.folder.cfcname". btw, slash "/" doesn't work here.

<cfcomponent>
<cffunction name="myMethod" returntype="myVersion.myPackage.myComponent" access="public">
<cfset result = CreateObject("component", "myVersion.myPackage.myComponent")>
<cfreturn result>
</cffunction>
</cfcomponent>

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
I needed to know if we could pass more than 1 arguments and return long strings...wondered for a while, tried to search for examples for a while and then decided to give it a shot. Here is a function I used to populate a <select> menu:

in the main program sequence, here is how I call the function:

<cfoutput>#createoption("yan","Yankton")#</cfoutput>

in the function, I compare a form element called stationz with "yan" (or any other short form for a station). If they are equal, I return an <option> tag with "selected" property otherwise I simply return the <option> tag.

Here goes the function:

<cffunction name="createoption" returntype="string">
<cfargument name="whatstation" type="string">
<cfargument name="propercasewhatstation">

<cfif #stationz# eq #whatstation#>
<cfreturn "<option value='#whatstation#' selected>#propercasewhatstation#</option>">
<cfelse>
<cfreturn "<option value='#whatstation#'>#propercasewhatstation#</option>">
</cfif>
</cffunction>

This helped me reduce coding of 19 stations and it is going to help me for 180 more stations. I hope someone can get the idea from here and modify it to their own use.

Chirag Shukla.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
The void entry was incorrectly removed from the list of cffunction returnType attribute values.
You can use void as a returnType attribute value for all cffunction tags except for those where the access attribute is remote.
A function that is accessed remotely, such as by a web service, must return a value; otherwise, attempts to use the function remotely will cause errors.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
The question about "void" return type still have no answer... I'm interested too: it's supported or not? It's deprecated? If I use it could I run into problems with newer versions of CF?

I miss the "history" part of this tag too, like in "cfinvokeargument", for example, we read: "ColdFusion MX: Added this tag." Several tags in the documentation doesn't have this history information (like cfargument, cfcomponent, etc). You could review it.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
I think the information you want is available from this link: http://www.macromedia.com/support/coldfusion/ts/documents/cfmlhistory.htm

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Does this tag available in ColdFusion 5, I am sure not after spending 4 to 5 hours.

Along with the tag documentation Cold Fusion provides the versions as well on which these tag works!

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Got a problem with understanding returnType = a component name although I am not new to CF. Never seen it used (or didn't noticed). Could someone post an example of when to use it and how to use it?

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
I use void all the time w/o a hitch

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Is returnType="void" still valid and supported? The MX doc includes it, but the MX 6.1 doc here does not (see MX doc page http://livedocs.macromedia.com/coldfusion/6/CFML_Reference/Tags-pt145.htm#2852457 )

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Allen's comment has to do with the wording of the error message.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Why is that a bug? It should be a wanted feature to have the type Integer but Allen should use type Numeric until then.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
This has been entered as bug 53756.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
Hey guys. Love the livedocs.

CFFunction gave me a confusing error when I tried to pass in a return type of integer:

<cffunction name="AddCustomer" access="public" returntype="integer">

it should say that 'integer' isn't a valid return type rather than the return type isn't of type integer.

HTH,
Take Care,
Allen Manning, Prismix Ltd.

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
For more information, see the related discussion in the Developing ColdFusion MX Applications book:

UDFs: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/udfs.htm
ColdFusion Components: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/building.htm

LiveDocs Comments - coldfusion - 6.1 - htmldocs - tags-p43.htm
here should be nice example about cffunction to use a package and component type.
Honestly we need indepth example rather than kids plays show



[Top]


Recommended Books

[Top]

Web Sites

[Top]

Copyright © 2003- 2010, Orville Paul Chomer, All Rights Reserved