Solved

Passing CFC components

Posted on 2011-03-07
3
302 Views
Last Modified: 2012-05-11
I have  a component which I am calling and this has an argument called jetId which is not required.
The idea is that if I pass a jet Id the query excludes it.
The code then does <cfif isDefined("jetID")> Jet id is being found even when I don't pass the argument because there is a variable called jetid contained on the cfm page which is invoking the component.

Is there a way that allows an argument name to be the same as a variable?
0
Comment
Question by:Lmillard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:Lmillard
ID: 35066737
sorry, forgot to add code
cfm page invoking the component.


<cfinvoke component="#application.compPath#Jets" method="allJets"
    	returnvariable="allJets">



 the component function


<cfcomponent>
	<cffunction name="allJets" access="public" returntype="query">
		<cfargument name="jetId" type="numeric" required="no">
           
        <cfquery name="allJets" datasource="#application.dataDsn#">
        SELECT 
        jets.*,
        jetCat.catDesc,
        manufacturer.company 
        FROM Jets 
        INNER JOIN jetCat 
        ON jetCat.catID = jets.catID
        INNER JOIN Manufacturer 
        ON jets.manId = manufacturer.manId 
        WHERE status = 1 
        <cfif isDefined("jetID")>
        AND jetID <> #jetID#
        </cfif>
        ORDER BY jets.jetDesc
        </cfquery>
        

		<cfreturn allJets>
	</cffunction>
</cfcomponent>

Open in new window

0
 
LVL 18

Accepted Solution

by:
Plucka earned 500 total points
ID: 35066950
variables.jetId is the variable

arguments.jetId is the argument

if you use the scopes it should work.
0
 

Author Closing Comment

by:Lmillard
ID: 35067055
Worked perfectly, thanks very much.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question