School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 309,245 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,680 people online right now. Registration is fast and FREE... Join Now!




Passing argument-variables from cfinvoke to cfcomponent

 

Passing argument-variables from cfinvoke to cfcomponent, What am I doing wrong?

ComboAlex

10 Aug, 2009 - 04:37 PM
Post #1

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
OK, I am confused... error says:

"The DATASOURCE parameter to the MakeBreadCrumb function is required but was not passed in. "

But I am passing it! Don't I? Can anynone please help me solving this small problem?

Here's my .cfm code (<cfinvoke>):
CODE

<body>

<cfset databaseSource = "test"> <!--- defining the datasource (database name) --->
<cfset sourceTable = "testnavigation"> <!--- defining the table we will be getting the data from --->

<cfinvoke
component="cfdocs.Recursive Navigation.cfcomponents.navigation"
method="MakeBreadCrumb"
returnvariable="MakeBreadCrumbRet">
    <cfinvokeargument name="id" value="#URL.item#"/>
    <cfinvokeargument name="cnt" value="1"/>
    <cfinvokeargument name="dataSource" value="#databaseSource#"/>
    <cfinvokeargument name="table" value="#sourceTable#"/>
</cfinvoke>

</body>


And here's my .cfc code (<cfcomponent><cffunction>):
CODE

<component>
<cffunction name="MakeBreadCrumb" access="public" returntype="array">
    <cfargument name="id" type="numeric" required="yes" default=0 >
    <cfargument name="cnt" type="numeric" required="yes" default=0 >
    <cfargument name="dataSource" type="string" required="yes" >      
    <cfargument name="table" type="string" required="yes">      
    
    <cfif arguments.cnt IS 0>        
        <cfset breadCrumbArray=ArrayNew(1)>
    </cfif>            
    
    <cfquery name="qryItem" datasource="#dataSource#">
        SELECT parentid
        FROM #table#
        WHERE id = #arguments.id#
    </cfquery>    
    
    <cfset breadCrumbArray[#arguments.cnt#]=arguments.id>
    
    <cfif qryItem.parentid IS NOT 0>
        <cfset MakeBreadCrumb(id = qryItem.parentid, cnt = arguments.cnt + 1) >
    <cfelse>
        <cfset reversedBreadCrumbArray = reverseArray(inputArray = breadCrumbArray)>        
    </cfif>
    
    <cfreturn reversedBreadCrumbArray>
    
</cffunction>
</component>


User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 7)

ComboAlex

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

11 Aug, 2009 - 02:02 PM
Post #2

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
OMG! It's so hard to get a simple answer to a simple question here! crazy.gif icon_down.gif

Can anyone help, please?
User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

12 Aug, 2009 - 07:14 AM
Post #3

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 268



Thanked: 2 times
My Contributions
QUOTE(ComboAlex @ 11 Aug, 2009 - 02:02 PM) *

OMG! It's so hard to get a simple answer to a simple question here! crazy.gif icon_down.gif

Can anyone help, please?


First off. This isn't a simple question.
Can you do a print screen of the full error that you get and post it here?
User is offlineProfile CardPM
+Quote Post

ComboAlex

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

12 Aug, 2009 - 07:50 AM
Post #4

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
Yep, give me two minutes. smile.gif

QUOTE(xheartonfire43x @ 12 Aug, 2009 - 07:14 AM) *

QUOTE(ComboAlex @ 11 Aug, 2009 - 02:02 PM) *

OMG! It's so hard to get a simple answer to a simple question here! crazy.gif icon_down.gif

Can anyone help, please?


First off. This isn't a simple question.
Can you do a print screen of the full error that you get and post it here?


Here you go. Tell me if you need anything else.

IPB Image

User is offlineProfile CardPM
+Quote Post

ComboAlex

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

12 Aug, 2009 - 08:09 AM
Post #5

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
If it helps here is the other report window of the same problem.



The only thing I changed in the code it's the path to the component. But don't worry, this is not the problem, cause it's set properly and the code is exactly the same as already posted.

Here's my code again just to be sure...

CODE

<component>
<cffunction name="MakeBreadCrumb" access="public" returntype="array">
    <cfargument name="id" type="numeric" required="yes" default=0 >
    <cfargument name="cnt" type="numeric" required="yes" default=0 >
    <cfargument name="dataSource" type="any" required="yes">      
    <cfargument name="dataTable" type="any" required="yes">      
    
    <!--- we make a new array which will hold all the parents (parentid values), but we declare it only the
    first time in the recursive call --->    
    <cfif arguments.cnt IS 0>        
        <cfset breadCrumbArray=ArrayNew(1)>
    </cfif>        
    
    <!--- selecting the current parentid --->    

    
    <cfquery name="qryItem" datasource="#arguments.dataSource#">
        SELECT parentid
        FROM #arguments.dataTable#
        WHERE id = #arguments.id#
    </cfquery>
    
    <!--- saving the current parentid to the array --->
    <cfset breadCrumbArray[#arguments.cnt#]=arguments.id>
    
    <cfif qryItem.parentid IS NOT 0> <!--- if we reached the root level of the navigation --->
        <!--- HERE WE MAKE THE RECURSIVE CALL of "MakeBreadCrumb" function - the input argument
        becomes the current <parentid> from the <qryItem> query --->
        <cfset MakeBreadCrumb(id = qryItem.parentid, cnt = arguments.cnt + 1) >
    <cfelse> <!---  if we still haven't reached the root level --->
        <!--- we reverse the breadCrumb array so we can "follow the bread crumbs" from start to the end
        in the correct order --->
        <!--- here is where we use the above written "reverseArray" function --->        
        <cfset reversedBreadCrumbArray = reverseArray(inputArray = breadCrumbArray)>        
    </cfif>
    
    <cfreturn reversedBreadCrumbArray>
    
</cffunction>
</component>


CODE

<cfset databaseSource = "test"> <!--- defining the datasource (database name) --->
<cfset sourceTable = "testnavigation"> <!--- defining the table we will be getting the data from --->

<cfinvoke
component="cfdocs.GlobeKrasCMS.cfcomponents.navigation"
method="MakeBreadCrumb"
returnvariable="MakeBreadCrumbRet">
    <cfinvokeargument name="id" value="#URL.item#"/>
    <cfinvokeargument name="cnt" value="1"/>
    <cfinvokeargument name="dataSource" value="#databaseSource#"/>
    <cfinvokeargument name="dataTable" value="#sourceTable#"/>
</cfinvoke>





The funny thing is that it accepts the first two arguments I am passing in the exact way as the last two, but somehow it doesn't recognize the last two I need for the database. Very very odd. It must be some stupid error I am doing. It always is in cases like this. smile.gif I just cannot see it.

I guess I found out where the problem was. I wasn't reading the error report well enough. smile.gif Let me try to add some more arguments in the line 67. smile.gif

This post has been edited by ComboAlex: 12 Aug, 2009 - 08:05 AM
User is offlineProfile CardPM
+Quote Post

ComboAlex

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

12 Aug, 2009 - 08:16 AM
Post #6

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
Problem solved!!! Oh my... I feel so stupid... smile.gif

Check out the comment in the code.

CODE

<component>
<cffunction name="MakeBreadCrumb" access="public" returntype="array">
    <cfargument name="id" type="numeric" required="yes" default=0 >
    <cfargument name="cnt" type="numeric" required="yes" default=0 >
    <cfargument name="dataSource" type="string" required="yes">      
    <cfargument name="dataTable" type="string" required="yes">
    
    <cfif arguments.cnt IS 0>        
        <cfset breadCrumbArray=ArrayNew(1)>
    </cfif>    
    
    <cfquery name="qryItem" datasource="#arguments.dataSource#">
        SELECT parentid
        FROM #arguments.dataTable#
        WHERE id = #arguments.id#
    </cfquery>
    
    
    <cfset breadCrumbArray[#arguments.cnt#]=arguments.id>
    
    <cfif qryItem.parentid IS NOT 0>
        <!--- THE PROBLEM WAS HERE. I FORGOT TO SET ALL THE ARGUMENTS IN HERE TOO!!! AAAAAAAAAAAAAAARRRRRRRRRRRRRRRGHHHHHHHHHHHHHH  :) SORRY MY FRIENDS!!!! --->
        <cfset MakeBreadCrumb(id = qryItem.parentid, cnt = arguments.cnt + 1, dataSource = arguments.datasource, dataTable = arguments.dataTable) >
    <cfelse>    
        <cfset reversedBreadCrumbArray = reverseArray(inputArray = breadCrumbArray)>        
    </cfif>
    
    <cfreturn reversedBreadCrumbArray>
    
</cffunction>
</component>


And of course... the <cfcomponent> was not written correctly. Now it should be fine. smile.gif I changed that too.

THANK YOU GUYS A LOT!

This post has been edited by ComboAlex: 12 Aug, 2009 - 08:17 AM
User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

12 Aug, 2009 - 07:57 PM
Post #7

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 268



Thanked: 2 times
My Contributions
The error that is being shown is not the same as the code you are posting.

The specific line to look at is
CODE

67: <cfset MakeBreadCrumb(id=qryItem.parentid, cnt=arguments.cnt + 1)>


That line clearly has no datasource argument passed in. You need to read what your error tells you before you post to a forum. ColdFusion is pretty good with errors. It tells you the line number, and the code, and exactly what is wrong.
User is offlineProfile CardPM
+Quote Post

ComboAlex

RE: Passing Argument-variables From Cfinvoke To Cfcomponent

13 Aug, 2009 - 01:12 PM
Post #8

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
Thank you for helping. I usually check the error report very well, but I was too tired so I missed it. My bad.

This post has been edited by ComboAlex: 13 Aug, 2009 - 01:13 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/26/09 09:32AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month