Cffunction returntype
If I have a cffunction within a cfc that simply does an
update on the DB should I use returntype="void"?
How about not even specifying the returntype?
Thanks!
Tend to agree here - if you havea requirement for strong
typing you probably
shouldn't be using coldfusion. These days, it seems we either
want to work
with dynamic languages or more tradiotonal "compiled"
languages. And the
choice for dynamic languages is usually made on "the need for
speed" at
development time - strong typing would seem to run contrary
to this idea.
Btw - even in compiled languages (java, c#) you can still get
type errors at
runtime - compliler cannot catch them all unfortunately. (eg;
cast errors,
null reference errors)
"Hal B. Helms" <[email protected]> wrote in
message
news:f72sfs$los$[email protected]..
> The question is one of whether ANY typing should be
used. The goal of
> typing
> variables is "type safety" -- the assurance that no data
type mismatches
> can
> occur. In a strongly-typed language such as Java or C#,
this happens at
> compile
> time and it's very helpful.
>
> In a weakly-typed language such as ColdFusion or Ruby,
the only time
> type-checking can be done is at run time. This is much,
much less helpful.
> My
> own personal opinion is to omit all typing of variables.
There's so little
> to
> gain and quite a cost involved (beyond the finger
typing).
>
Similar Messages
-
Cffunction returntype question
I've got a function (below) in a CFC that executes a stored
procedure. The procedure has 2 input parameters and a single output
parameter. I want to cfoutput the value of the output parameter in
the procedure. The procedure does it's job in CF if I don't return
the output parameter. I keep having problems with the
returnvariable type. I've output returntypes of query in the past
without any problem, but never a single calculated value. The value
being output by the procedure is a long integer.
<!--- FUNCTION --->
<cffunction name="myFunctTest" hint="ProcedureTest"
returntype="??????">
<cftry>
<cfstoredproc procedure="myProc" username='#this.user#'
password='#this.pass#' datasource='#this.dSource#'>
<cfprocparam type="Out" cfsqltype="cf_sql_integer"
variable="OutputID"><!--- Output variable I want to return
--->
<cfprocparam type="In" cfsqltype="CF_SQL_INTEGER"
value='#this.par1#' dbvarname="myPar1">
<cfprocparam type="In" cfsqltype="CF_SQL_VARCHAR"
value='#this.par2#'dbvarname="myPar2">
</cfstoredproc>
<cfcatch type="any">
<cfreturn "Error in Function...">
</cfcatch>
</cftry>
<cfreturn ??????>
</cffunction>
<!--- FUNCTION CALL --->
<cfinvoke component="cfc.myCFC" method="myFunctTest"
returnvariable="??????">
<cfinvokeargument name="user" value="#myUser#">
<cfinvokeargument name="pass" value="#MyPass#">
<cfinvokeargument name="dSource" value="#myDSource#">
<cfinvokeargument name="par1" value="#Form.MyPar1#">
<cfinvokeargument name="par2" value="#Form.MyPar2#">
</cfinvoke>
Thanks in advance
Roy.Combine,
Are your stored procedure parameters defined in the same
order you are using them in your CFSTOREDPROC tag? Bear in mind
that the dbvarname attribute is ignored in CF6+. -
"The value returned from the addRequirement function is not
of type query" is what I get when I execute the below function.
This works fine in 7, but in 8 I get that error. Any ideas?
<CFFUNCTION NAME="addItem" output="false"
returntype="query">
<CFARGUMENT NAME="userid" TYPE="numeric"
REQUIRED="true">
<CFARGUMENT NAME="title" TYPE="string"
REQUIRED="true">
<cfset var addRequirement = "">
<CFQUERY NAME="addItem" datasource="#variables.dsn#">
INSERT INTO test(userID,title)
VALUES (#ARGUMENTS.userID#,'#arguments.title#')
</CFQUERY>
<cfreturn addItem>
</CFFUNCTION>In addition to the insert not returning a result set, you
have your var declared as 'addRequirement'
but your query name and return value are 'addItem'
If it were me, I'd set the return type to boolean, then set a
var result = 'FALSE'. Wrap the insert query in a CFTRY and if it's
sucessful, set result = 'TRUE' and then return result -
Webservice cffunction returntype="xml" complex datatype problems WSDL
Ho do I create complex data types in my WSDL when using
returntype="xml"??
I have tried a few different things but for the life of me I
cannot figure it out.If you open the Developer Guide of CFMX7
(cfmx7_dev_guide.pdf) page 909, there is a description how to
handle complex data types.
Laksma -
Issue with autosuggest on a numeric field
I have a form with a CFINPUT that has autosuggest to a cfc.
The cfc runs a query against a varchar field that has only numeric
values. When the match is made and the lis is returned I get an
error (Bind failed for autosuggest CUSTOMER, bind value is not a 1D
array of strings). This only happens with fields that are all
numeric, if the field has any letters or symbols I do not have this
issue.
The data returned is coming back as numeric in scientific
notation (CFC invocation response: [5.159000038E9]) The data is
matching on the phone number and that is what is being returned.
It there a way to correct this issue? Code sample is below.
<cfinput type="text" name="CUSTOMER" size="10"
maxlength="10" value="#CUSTOMER#"
autosuggest="cfc:customerInfo.getCustomerSuggest({DSN},
{cfautosuggestvalue})">
here is the function from the CFC:
<cffunction name="getCustomerSuggest" access="remote"
returntype="array" output="false">
<cfargument name="argDB" type="string" required="yes">
<cfargument name="argCUSTOMER" type="string"
required="yes">
<cfset var myarray = ArrayNew(1)>
<cfquery name="cstInfo" datasource="#argDB#"
maxrows="25">
SELECT customer
FROM custFile
WHERE customer LIKE <cfqueryparam value="#argCUSTOMER#%"
cfsqltype="CF_SQL_VARCHAR">
</cfquery>
<cfloop query="cstInfo">
<cfset arrayAppend(myarray, '#customer# ')>
</cfloop>
<cfreturn myarray>
</cffunction>I don't understand the actual results desired. But I would
make my cffunction returntype a string and get rid of the cfloop
that creates your array. One of my autosuggest cfcs is;
<cffunction name="getJobsearch" access="remote"
returnType="string" output="false">
<cfargument name="term" type="string"
required="false">
<cfset var Jqry = "">
<cfquery name="Jqry" datasource="taxsearchdb">
SELECT J.CompanyName + ' ' + J.CompanyCity + ' ' + C.State +
' ^' + cast(J.JobOrderNumber as varchar) as Jname
FROM jorder J, Companies C
WHERE J.CompanyNumber = C.CompanyRecordNumber and
J.CompanyName LIKE <cfqueryparam cfsqltype="cf_sql_var"
value="#trim(arguments.term)#%">
</cfquery>
<cfreturn ValueList(Jqry.Jname)>
</cffunction> -
I just picked up coldfusion about a month ago, so my
coldfusion lingo sucks. I have been programming in C++ for over 5
years now and will be using a lot of C++ terminology to help avoid
any confusion. I am writing a cfc function that preforms web
servicing. This function needs to return an object/class that is
defined in another coldfusion function. I can do this without a
problem if I only need to return one instance of this object.
However, I cannot seem to return an array of this object (I need to
return multiple instances of this object, kind of like a query, but
for programming purposes it needs to stay as an object).
It seems that the webservicing function hates my return type.
If I try to make an array of the object, it does not like array or
the object as the return type. However, when I take this function
out of the cfc, and make it a cfm, it gets the array of objects
just fine. So, I think I am having issues with the return type on
the <cffunction> tag. So I came up with the idea of creating
another object which will hold an array of the first object and
using the second object as the return type. Here is some psuedo
code of the function I am working on:
<cffunction name="SelectGames" access="remote"
returntype="ArrayOfGames" output="false">
<!-- arguments --->
<!--- query --->
<cfobject component = "myArray" name>
<cfobject component="games" name="test">
<cfset counter = 0>
<cfloop query="getevents">
<cfset counter = counter + 1>
<cfset test.Game_id = event_id>
<cfset test.gameDate = eventdate>
<cfset test.Starttime = starttime>
<cfset test.Place = place>
<cfset test.Level = level>
<cfset test.Sport = sport>
<cfset test.Gender = division>
<cfset test.Opponent = opponent_id>
<cfset test.Type = type>
<cfset test.Link = spec_name>
<cfset myArray.gamesArray[counter] = test>
</cfloop>
<cfreturn myArray>
</cffunction>
It keeps telling me that it does not recognize the return
type.
Here are examples of the two objects I am using from the 2
dif. cfc files:
<cfcomponent>
<cfproperty name="gamesArray" type="array">
</cfcomponent>
<cfcomponent>
<cfproperty name="Game_id" type="numeric">
<cfproperty name="gameDate" type="date">
<cfproperty name="Starttime" type="string">
<cfproperty name="Place" type="string">
<cfproperty name="Level" type="string">
<cfproperty name="Sport" type="string">
<cfproperty name="Gender" type="string">
<cfproperty name="Opponent" type="string">
<cfproperty name="Type" type="string">
<cfproperty name="Link" type="string">
</cfcomponent>
Feel free to post any questions to clear anything up, I know
this is confusing and I probably did a poor job of explaining my
problem. Also, if I throw this code into a cfm and try to make an
array of games, it works, this is the code I got it to work with:
<cfset myArray = newArray(1)>
<cfloop query="getevents">
<cfset counter = counter + 1>
<cfset test.Game_id = event_id>
<cfset test.gameDate = eventdate>
<cfset test.Starttime = starttime>
<cfset test.Place = place>
<cfset test.Level = level>
<cfset test.Sport = sport>
<cfset test.Gender = division>
<cfset test.Opponent = opponent_id>
<cfset test.Type = type>
<cfset test.Link = spec_name>
<cfset myArray[counter] = test>
</cfloop>
I guess my problem is I do not know how to specify a type for
an array.The return type of this FUNCTION would be returnType="array".
No matter
what kind of data the array contained.
That's what I get for fast proofing.
Ian Skinner wrote:
> I would have to play with your code more if this does
not clear it up
> for you, but lets start with this simple concept first.
>
> You mentioned "typing the array" several times.
ColdFusion is typeless,
> you don't type an array, it is just array. An array of
strings is the
> same as an array of integers which is the same as an
array of objects.
>
> So if you had a function something like this.
>
> <cffunction returnType="array" ...>
> <cfset theArray = arrayNew()>
>
> <cfloop ...>
> <cfset arrayAppend(theArray, newObject)>
> </cfloop>
>
> <cfreturn theArray>
> </cffunction>
>
> The return type of this function would be
returnType="array". No matter what
> kind of data the array contained.
>
> mwiley63 wrote:
>> I just picked up coldfusion about a month ago, so my
coldfusion lingo
>> sucks. I have been programming in C++ for over 5
years now and will
>> be using a lot of C++ terminology to help avoid any
confusion. I am
>> writing a cfc function that preforms web servicing.
This function
>> needs to return an object/class that is defined in
another coldfusion
>> function. I can do this without a problem if I only
need to return
>> one instance of this object. However, I cannot seem
to return an
>> array of this object (I need to return multiple
instances of this
>> object, kind of like a query, but for programming
purposes it needs to
>> stay as an object).
>> It seems that the webservicing function hates my
return type. If I
>> try to make an array of the object, it does not like
array or the
>> object as the return type. However, when I take this
function out of
>> the cfc, and make it a cfm, it gets the array of
objects just fine.
>> So, I think I am having issues with the return type
on the
>> <cffunction> tag. So I came up with the idea
of creating another
>> object which will hold an array of the first object
and using the
>> second object as the return type. Here is some
psuedo code of the
>> function I am working on:
>>
>> <cffunction name="SelectGames" access="remote"
>> returntype="ArrayOfGames" output="false">
>> <!-- arguments --->
>> <!--- query --->
>> <cfobject component = "myArray" name>
>> <cfobject component="games" name="test">
>> <cfset counter = 0>
>> <cfloop query="getevents">
>> <cfset counter = counter + 1>
>> <cfset test.Game_id = event_id>
>> <cfset test.gameDate = eventdate>
>> <cfset test.Starttime = starttime>
>> <cfset test.Place = place>
>> <cfset test.Level = level>
>> <cfset test.Sport = sport>
>> <cfset test.Gender = division>
>> <cfset test.Opponent = opponent_id>
>> <cfset test.Type = type>
>> <cfset test.Link = spec_name>
>> <cfset myArray.gamesArray[counter] = test>
>> </cfloop>
>> <cfreturn myArray>
>> </cffunction>
>>
>> It keeps telling me that it does not recognize the
return type.
>> Here are examples of the two objects I am using from
the 2 dif. cfc
>> files:
>> <cfcomponent>
>> <cfproperty name="gamesArray" type="array">
>> </cfcomponent>
>> <cfcomponent>
>> <cfproperty name="Game_id" type="numeric">
>> <cfproperty name="gameDate" type="date">
>> <cfproperty name="Starttime" type="string">
>> <cfproperty name="Place" type="string">
>> <cfproperty name="Level" type="string">
>> <cfproperty name="Sport" type="string">
>> <cfproperty name="Gender" type="string">
>> <cfproperty name="Opponent" type="string">
>> <cfproperty name="Type" type="string">
>> <cfproperty name="Link" type="string">
>> </cfcomponent>
>>
>> Feel free to post any questions to clear anything
up, I know this is
>> confusing and I probably did a poor job of
explaining my problem.
>> Also, if I throw this code into a cfm and try to
make an array of
>> games, it works, this is the code I got it to work
with:
>> <cfset myArray = newArray(1)>
>> <cfloop query="getevents">
>> <cfset counter = counter + 1>
>> <cfset test.Game_id = event_id>
>> <cfset test.gameDate = eventdate>
>> <cfset test.Starttime = starttime>
>> <cfset test.Place = place>
>> <cfset test.Level = level>
>> <cfset test.Sport = sport>
>> <cfset test.Gender = division>
>> <cfset test.Opponent = opponent_id>
>> <cfset test.Type = type>
>> <cfset test.Link = spec_name>
>> <cfset myArray[counter] = test>
>> </cfloop>
>>
>> I guess my problem is I do not know how to specify a
type for an array.
>> -
Issue with AutoSuggest + UpdateContent
Hi,
Using Spry.Utils.updateContent when I load part of a page
containing an AutoSuggest the AutoSuggest breaks.
Seems like the XML datasource is not fired in that case. If I
put the AutoSuggest code out of the destination DIV it works.
Click here to see what I
mean
I'm using v1.5. Any clue ? Thanks.I don't understand the actual results desired. But I would
make my cffunction returntype a string and get rid of the cfloop
that creates your array. One of my autosuggest cfcs is;
<cffunction name="getJobsearch" access="remote"
returnType="string" output="false">
<cfargument name="term" type="string"
required="false">
<cfset var Jqry = "">
<cfquery name="Jqry" datasource="taxsearchdb">
SELECT J.CompanyName + ' ' + J.CompanyCity + ' ' + C.State +
' ^' + cast(J.JobOrderNumber as varchar) as Jname
FROM jorder J, Companies C
WHERE J.CompanyNumber = C.CompanyRecordNumber and
J.CompanyName LIKE <cfqueryparam cfsqltype="cf_sql_var"
value="#trim(arguments.term)#%">
</cfquery>
<cfreturn ValueList(Jqry.Jname)>
</cffunction> -
Cffunction, onSessionEnd throwing an error, please help
Hello;
I am using an application.cfc file to run my web site. I
added an argument for onmissingtemplate and when I did that, it
made my onSessionEnd statement throw an error:
this is my statement:
<cffunction name="onSessionEnd" returnType="void">
<cfargument name="theSession" type="struct"
required="true">
<cfset var duration =
dateDiff("s",arguments.theSession.created,now())>
<cflog file="#THIS.name#" text="Session lasted for
#duration# seconds.">
</cffunction>
and this is the error:
Invalid CFML construct found on line 85 at column 1.
ColdFusion was looking at the following text:
<
The CFML compiler was processing:
< marks the beginning of a ColdFusion tag.Did you mean LT
or LTE?
The error occurred in C:\Websites\4npp8b\Application.cfc:
line 85
83 : </cfcomponent>
84 :
85 : <cffunction name="onSessionEnd" returnType="void">
86 : <cfargument name="theSession" type="struct"
required="true">
87 : <cfset var duration =
dateDiff("s",arguments.theSession.created,now())>
I don't know if this will make a difference, but here is my
onsessionstart function:
<cffunction name="onSessionStart" returntype="any"
output="true">
<cfset SESSION.created = now()>
</cffunction>
I can't figure out what I did wrong to make it throw that
error. Any ideas?
CFmongernever mind, I figured it out. sorry to bother.
-
In flex, How to set a value to one parameter, the parameter
defined in a cffunction in a cfc file, In the cffunction there are
much cfargument, I want set a value to one of them, such as the
cfc:
<cffunction access="remote" name="myShow" output="false"
returntype="struct">
<cfargument name="ID" type="numeric" default=0>
<cfargument name="GoodsID" type="string" default="">
<cfargument name="DestTime" type="string" default="">
<cfargument name="DestCount" type="numeric" default=1>
How I set a value to only parameter one of them , such as set
GoodsID when use mx:remoteObject.
Thanks for your helpGot maybe a solution for you, I have just tested it.
So, the idea is to use intermediate variables. Imagine Var1 and Var2 variables that you refresh with your more or less complicated queries. Then what you can do is to refresh your final variable Var3 with a query using your intermediate variables. Here is an example for Oracle:
select #Var1+#Var2 from dual
This way you can make a chain of dependent variables: Var3 is using Var2 and Var2 is using Var1.
Hope it helps.
Shamil -
Don't understand cffunction and cfcomponent
I am trying to alter Forta's ajax related select tutorial to fit my needs. I am having trouble understanding the details of this .cfc though.
<cfcomponent output="false">
<!--- Get array of media types --->
<cffunction name="get_states" access="remote" returnType="array">
<cfset data="">
<cfset result=ArrayNew(2)>
<cfset i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,states
FROM state
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.state[i]>
</cfloop>
<cfreturn result>
</cffunction>
<!--- Get art by media type --->
<cffunction name="get_waters" access="remote" returnType="array">
<cfargument name="location" type="string" required="true" default="">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,name
FROM waters
WHERE bow_state = '#arguments.location#'
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction>
</cfcomponent>
When I put '#arguments.id#' into the second query, I get results. However, I'd like to query by the name instead, so I am trying location. I don't fully understand so I am hacking around with this a bit but I'd like to 1 - get results by name instead of id and 2 - understand the arguments variable so I really know what is going on.
Thanks!Sorry, didn't see this before I posted.
But I think my suggestion was in keeping with the example. If you need to select on "state", then make the "state" column of your first query to be the first value in the array that you return:
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,states
FROM state
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.state[i]>
<cfset result[i][2]=data.state[i]>
</cfloop>
This will make your select look something like this in the rendered HTML:
<select id="states" name="whatever...">
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
</select>
So then, on your second, dependent select, you'd specify the binding like so (just like you did, really):
<cfselect name="waters" bind="cfc:_ffc_cfc_select_jump.get_waters({states})" bindonload="false"></cfselect>
However, now, because the value of the "states" select options are state names, rather than ids, you should now be able to use the argument in your query based on state names:
<!--- Get art by media type --->
<cffunction name="get_waters" access="remote" returnType="array">
<cfargument name="location" type="string" required="true" default="">
<!--- Define variables --->
<cfset var data="">
<cfset var result=ArrayNew(2)>
<cfset var i=0>
<!--- Get data --->
<cfquery name="data" datasource="mydsn">
SELECT id,name
FROM waters
WHERE bow_state = <cfqueryparam value="#arguments.location#" cfsqltype="varchar" /> <!---Be sure to queryparam!!!--->
</cfquery>
<!--- Convert results to array --->
<cfloop index="i" from="1" to="#data.RecordCount#">
<cfset result[i][1]=data.id[i]>
<cfset result[i][2]=data.name[i]>
</cfloop>
<!--- And return it --->
<cfreturn result>
</cffunction> -
Dynamically nameing a CFfunction in a loop
I want to do this
loop through query results
<cffunction name= "#loop.ID#_test">
DO something with record of data from query
</cffunction>
now can I dynamically change the name of the cffunction ( and or Method)?
Can someone help me pleaseThis might help get help
this is what I have and it works but whenever I add something new it gets ver cumbersum
<cfcomponent displayname="F_QU_004_harness" extends="mxunit.framework.TestCase">
<cfobject component="setup" name="setupUtil">
<!--- read xml file templatevariables.xml --->
<CFFile action="READ" variable="xml" file="#ExpandPath('.')#\Templatevariables.xml">
<cfset mydoc = XmlParse(xml)>
<cfset MyDocArray =XmlSearch(mydoc,'SavedQuery')>
<!--- set up --->
<cffunction name="setUp" returntype="void" access="public" output="false">
<cfset this.selenium=setupUtil.setup()/>
</cffunction>
<!--- Shut down selenium --->
<cffunction name="tearDown" returntype="void" access="public" output="false">
<cfset setupUtil.tearDown()/>
</cffunction>
<!---set variables based on the index of the function --->
<cffunction name="variablesetup" access="Private">
<cfargument name="indexVar">
<cfscript>
this.queryId = #myDoc.xmlRoot.xmlChildren[indexVar]["queryId"].xmlText#;
this.queryName=#myDoc.xmlRoot.xmlChildren[indexVar]["queryName"].xmlText#;
this.UnqSQL =#myDoc.xmlRoot.xmlChildren[indexVar]["UniqueSQL"].xmlText#;
this.AllSql=#myDoc.xmlRoot.xmlChildren[indexVar]["AllSQL"].xmlText#;
</cfscript>
</cffunction>
<!--- the following are calls to the individual templates --->
<cffunction name="All_Bio_Samples" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<!--- the number in the variablesetup call corresponds to the index in the xml file to the template--->
<cfset variablesetup(1)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Asthma_All" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(2)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="COPD_All" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(3)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Asthma_Adults" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(4)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Asthma_Kids" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(5)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="COPD_Under_50" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(6)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="ILD_All" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(7)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Sleep_Apnea" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(8)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Rhinitis_All" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(9)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Rhinitis_Adults" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(10)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Rhinitis_Kids" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(11)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Sinusitis_All" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(12)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Sinusitis_Adults" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(13)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Alpha_1_antitrypsin_Deficiency" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(14)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
<cffunction name="Sleep_Apnea_Kids" returntype="void" access="public" output="false">
<cfset selenium=this.selenium/>
<cfset variablesetup(15)>
<cfinclude template="F_QI_004.cfm">
</cffunction>
</cfcomponent>
I want to do this more dynamically like read the XML and let the data drive instead of ME doing all that typing of the same thing OVER AND OVER -
First, has anyone used BlogCFC? this is dealing with it.
I have put parts of the pods and main content into iframes.
I now need every link to escape & target the top.
I have a problem with this code it seems...
quote:
<cfoutput><a href="#application.blog.makeLink(id)#"
target="_top">#title#</a><br></cfoutput>
And then in the blog.cfc file I find....
quote:
<cffunction name="makeLink" access="public"
returnType="string" output="false"
hint="Generates links for an entry.">
<cfargument name="entryid" type="uuid"
required="true">
<cfset var q = "">
<cfset var realdate = "">
<cfquery name="q" datasource="#instance.dsn#">
select posted, alias
from tblblogentries
where id = <cfqueryparam cfsqltype="cf_sql_varchar"
value="#arguments.entryid#" maxlength="35">
</cfquery>
<cfif q.alias is not "">
<cfset realdate = dateAdd("h", instance.offset,
q.posted)>
<cfreturn
"#instance.blogURL#/#year(realdate)#/#month(realdate)#/#day(realdate)#/#q.alias#">
<cfelse>
<cfreturn
"#instance.blogURL#?mode=entry&entry=#arguments.entryid#">
</cfif>
</cffunction>
Does anyone see from this why target="_top" does not work?
And am I missing the actual creation of makeLink?
seems like the cffunction just is getting the query for it.
I don't deal with cffunctions.Both are correct and will work, but cffunction has some
advantages. The biggest one is the cfargument tag which gives you
more control over the datatypes coming in. You could code all those
in cfscript, but it's now unnecessary. -
Hi,
I have a form where I fill a customer-no. into an input field and get the customer name using databinding.
This works fine, but when I put non-numeric values into customer-no I get following error:
Error invoking CFC customer.cfc : The CUST_ID argument passed to the getcustomer function is not of type numeric. [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
The message is correct, but how can I avoid to run the getcustomer function when the value is not numeric?
Here is my code:
The form:
<cfinput type="text" name="customer_no" style="width:140;background-color:yellow" maxlength="10" validate="integer" validateat="onblur" message="Customer No. format is integer">
<cfinput type="text" name="customer_name" style="width:170" maxlength="200" bind="cfc:customer.getcustomer({customer_no})" readonly="yes">
customer.cfc:
<cfcomponent >
<cffunction name="getcustomer" access="remote" returntype="string" output="yes" >
<cfargument name="cust_id" type="numeric" required="true" >
<cfset r_customer = "">
<cfquery name = "select_customer" dataSource = "x">
SELECT name
FROM customer
WHERE id = <cfqueryparam cfsqltype="cf_sql_numeric" value="#arguments.cust_id#" >
</cfquery>
<cfreturn r_customer>
</cffunction>
</cfcomponent>biene22 wrote:
The message is correct, but how can I avoid to run the getcustomer function when the value is not numeric?
That is a trick question! The attribute bind="cfc:customer.getcustomer({customer_no})" implies that the function will run automatically, whether or not customer_no is numeric. -
The argument TEAM passed to function SearchRes() is not of type numeric.
If the component name is specified as a type of this argument, the reason for this error might be that a definition file for such component cannot be found or is not accessible.
The error occurred in C:\Inetpub\wwwroot\search.cfc: line 4
2 :
3 : <cffunction name="SearchRes" access="public" returntype="query">
4 : <cfargument name="DSN" type="string" required="yes">
5 : <cfargument name="Role" type="string" required="no">
6 : <cfargument name="Team" type="numeric" required="no">
Please look at the above error...any help app...
code ------------------------->
<cfcomponent hint="This cfc does search...">
<cffunction name="SearchRes" access="public" returntype="query">
<cfargument name="DSN" type="string" required="yes">
<cfargument name="Role" type="string" required="no">
<cfargument name="Team" type="numeric" required="no">
<cfargument name="Level" type="numeric" required="no">
<cfargument name="zone" type="numeric" required="no">
<cfargument name="Dept" type="numeric" required="no">
<cfargument name="location" type="numeric" required="no">
<cfargument name="csgid" type="string" required="no">
<cfargument name="status" type="string" required="no">
<cfargument name="filter" type="string" required="no">
<cfargument name="bosseid" type="string" required="no">
<cfdump var="#arguments#">
<cfquery datasource="#arguments.DSN#" name="SearchRes">
Select
r.First_name,
r.Last_name,
r.EID,
r.tech_id,
r.title,
r.hire_date,
r.rehire_date,
l.location,
d.department
from
OPS$RMS.REF_resource r,
OPS$RMS.Ref_department d,
OPS$RMS.REF_Location l
where
r.location_code = l.location_code
And r.department_code = d.department_code
<cfif arguments.role neq "">
And r.role_code = '#arguments.role#'
</cfif>
<cfif arguments.Team neq "">
And r.team_code = #arguments.team#
</cfif>
<cfif arguments.level neq "">
And r.level_code = #arguments.level#
</cfif>
<cfif arguments.zone neq "">
--And r.zone_code = #arguments.zone#
</cfif>
<cfif arguments.dept neq "">
And r.department_code = #arguments.dept#
</cfif>
<cfif arguments.location neq "">
And r.location_code = #arguments.location#
</cfif>
<cfif arguments.csgid neq "">
And r.csg_operator_id like '#arguments.csgid#%'
</cfif>
<cfif arguments.status neq "">
And r.status = '#arguments.status#'
</cfif>
<cfif arguments.filter neq "">
And
r.EID = '#arguments.filter#%'
OR r.First_name like '#arguments.filter#%'
OR r.last_name like '#arguments.filter#%'
OR r.tech_id like '#arguments.filter#%'
</cfif>
<cfif arguments.bosseid neq "">
And r.boss_id = '#arguments.bosseid#%'
</cfif>
</cfquery>
<cfreturn SearchRes>
</cffunction>
</cfcomponent>craigkaminsky wrote:
Might not be an issue but, while your Team variable can be null, the cfargument tag types the variable as a numeric value (as opposed to any or whatever). Depending on what you're supplying this could be a source of the error.
As mentioned we would have to see the code. But that could well be the problem. There is really no concept of a "null" form field. If you are passing in the values of text fields, empy fields will be treated as an empty string "". Since an empty string is not numeric, it would cause exactly the error you are describing.
<!--- simulate an empty form field ---->
<cfset form.someField = "" />
<cfoutput>#test(form.someField)#</cfoutput>
<cffunction name="test" returntype="string">
<cfargument name="someValue" type="numeric" />
<cfreturn "okay"/>
</cffunction> -
Hello to everyone !
I have a problem to upload a file with cffunction :
i created a cfc with a function 'upload' :
<cffunction name="upload" access="remote"
returntype="void">
<cfargument name="image_big" type="any" required="no">
<cffile action="upload" fileField="#arguments.image_big#"
destination = "mylocation" nameConflict="overwrite"
accept="image/*">
</cffunction>
but it doesn’t work with out submitting the form ..
pleas help ..
thanks !I believe you need to have the file submitted via a form if
you want to use the <cffile action="upload" fileField="">
method of cffile. Otherwise, how will the server gain access to the
file itself?
Maybe you are looking for
-
How do i import pictures from my old iMac directly to my new iMac using iPhoto?
Hello! I have just got a new iMac and I am struggling with Migration Assistant to transfer data from my old iMac to the new one I have tried to follow the standard procedure with firewire cable without luck I am now desperately trying to find a smart
-
Producing musicals, I wish there was a "chunk" feature like in DP
Hi guys, especially iSchwartz, Jim, Rohan... This is another day I wished there was a chunk feature like in DP. Maybe you have a few tips for me. I'm doing a recording of another musical: lots of songs, lots of dialogues, lots of special effects. It
-
Help!
-
MBAM 2.5 - Antimalware exceptions
Does anyone have a list of files & processes to exclude from scanning? A FEP/SCEP template file would be even better if anyone has one ;) cheers Dave
-
Can i use 1 apple id on 2 iphones?
Hi. I have the iphone 4S . I might be getting the 5 soon. If my iphone 4S doesnt work anymore, could i use it on my iphone 5? Also, if i can, would i hve to reinstall all apps or would they just import?