the LightList=StructNew()... LightList=CreateObject() is modified from
the MX WACK appendixes examples for cfinvoke (pg 1218 & 1219).
I tried your suggestion for MyQuery=LightList.selectlist and it
worked. for a while. when I try to run the page now, I get a '
Context validation error for tag cffunction'. CFMX seems to think
there's no </cffunction> at the end of the cfcomponent, although there
is. this doesn't make any sense.
background:
The cfc is intended to generate four lists of data on the screen so
the user can select an item to view. The list items will vary based
on five parameters. (The existing page gets hit several thousand
times a month.)
After reviewing the code recently, I found I could streamline it into
one query that only needed a few parameters to execute properly.
Then, I learned about cfc's and figured that would be a more secure
and efficient way of generating the lists.
I've finally gotten it to work the way I want, but now I've got this
bloody error to figure out!!
Any help appreciated.
Chris
On Thu, 10 Feb 2005 16:03:58 -0600, Matt Woodward <[EMAIL PROTECTED]> wrote:
> A bit tricky to debug this without the database, etc. but here are
> some suggestions and questions.
>
> 1. Why do you do LightList = StructNew() and then immediately do
> LightList = CreateObject() ... ? (Same question for your other
> objects as well.)
>
> 2. Since your function returns something you have to set that to a
> variable. Calling LightList.selectList() returns a query, so you'll
> want to do something like this:
> myQuery = LightList.selectList(etc. ...)
>
> 3. I'm a bit unclear as to what you're dumping. Dumping your object
> isn't going to show you your results. (In general dumping the object
> doesn't give you as much info as you might imagine!)
>
>
> On Wed, 9 Feb 2005 21:27:02 -0600, Chris Gomez <[EMAIL PROTECTED]> wrote:
> > I've created the following code based on Tom and Matt's suggestion,
> > but all it does, according to a cfdump, is return the following. The
> > method should return two attributes (fldMass and fldName) and add them
> > to the structure.
> >
> > Any ideas for a cfc newbie?
> >
> > CFDUMP results
> > SELECTLIST
> > function selectList
> > Arguments:
> > Name Required Type Default
> > XFaction Required Any 1
> > XVType Required Any 1
> > XWeight Required Any 1
> > XEra Required Any 2
> > Return Type: query
> > Roles:
> > Access: package
> > Output: Yes
> >
> > <cfscript>
> > LightList = StructNew();
> > LightList = createObject("component","unitlist");
> > LightList.selectList(XFaction=1,XEra=2,XVType=1,XWeight=1);
> > MedList = StructNew();
> > MedList = createObject("component","unitlist");
> > MedList.selectList(XFaction=1,XEra=2,XVType=1,XWeight=2);
> > HvyList = StructNew();
> > HvyList = createObject("component","unitlist");
> > HvyList.selectList(XFaction=1,XEra=2,XVType=1,XWeight=3);
> > AsltList = StructNew();
> > AsltList = createObject("component","unitlist");
> > AsltList.selectList(XFaction=1,XEra=2,XVType=1,XWeight=4);
> > </cfscript>
> >
> > <cfcomponent>
> > <cffunction name="selectList" access="package" returntype="query">
> > <cfargument name="XFaction" required="true" default="1">
> > <cfargument name="XVType" required="true" default="1">
> > <cfargument name="XWeight" required="true" default="1">
> > <cfargument name="XEra" required="true" default="2">
> > <cfquery name="nameList" datasource="btech">
> > SELECT
> > t.fldName,
> > m.fldMass
> > FROM tblTRO t, tblWeightClass w, tblVType v, tblMass m,
> > tblFaction f, tblEra e, tblClass c
> > WHERE f.fldFactionID = t.fldFaction AND
> > w.fldWeightClassID = t.fldWeight AND
> > m.fldMassID = t.fldMass AND
> > c.fldClassID = t.fldClass AND
> > v.fldVTypeID = t.fldType AND
> > e.fldEraID = t.fldEra AND
> > (t.fldType = #arguments.XVType#) AND (t.fldFaction =
> > #arguments.XFaction#) and (t.fldEra = #arguments.XEra#) AND
> > (t.fldWeight = #arguments.XWeight#)
> > ORDER BY t.fldMass, t.fldName
> > </cfquery>
> > <cfreturn nameList>
> > </cffunction>
> > </cfcomponent>
> >
> > On Wed, 9 Feb 2005 08:46:30 -0600, Schreck, Tom <[EMAIL PROTECTED]> wrote:
> > > You can use the <cfinvoke> but the <cfinvoke> creates the CFC, calls a
> > > method, and then destroys the CFC. So, if you need to call only a single
> > > method from a CFC, then it's ok to use <cfinvoke>. If you need to call
> > > multiple methods from same cfc instance, then <cfinvoke> uses a lot of
> > > overhead.
> > >
> > > Most of the time you will need to call multiple methods of an object. So
> > > you can use createobject method within a <cfscript> block:
> > >
> > > <cfscript>
> > > oCFC =
> > > createObject("component","Package.Path.To.Where.CFC.Lives");
> > > oCFC.method1(paramName=paramValue,paramName1=paramValue1,...);
> > > oCFC.method2(paramName=paramValue,paramName1=paramValue1,...);
> > > etc.
> > > </cfscript>
> > >
> > > Another alternative to passing a list of name/value pairings is to create
> > > a
> > > structure containing data and use argumentcollection=structureName in
> > > place
> > > of all the name/value pairings.
> > >
> > > Thanks
> > >
> > > Tom Schreck
> > > 972-361-9943
> > > -----Original Message-----
> > > From: Chris Gomez [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, February 09, 2005 8:31 AM
> > > To: [email protected]
> > > Subject: CFC question
> > >
> > > At last nights meeting, it was brought up that CFC's should not be
> > > called using the CFINVOKE command. If that's the case, then how would
> > > you call a CFC and, more importantly, how do you call a CFC that
> > > requires arguments be passed to it?
> > >
> > > Thanks,
> > >
> > > Chris
> > > ----------------------------------------------------------
> > > To post, send email to [email protected]
> > > To unsubscribe:
> > > http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
> > > To subscribe:
> > > http://www.dfwcfug.org/form_MemberRegistration.cfm
> > >
> > > ----------------------------------------------------------
> > > To post, send email to [email protected]
> > > To unsubscribe:
> > > http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
> > > To subscribe:
> > > http://www.dfwcfug.org/form_MemberRegistration.cfm
> > >
> > >
> > ----------------------------------------------------------
> > To post, send email to [email protected]
> > To unsubscribe:
> > http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
> > To subscribe:
> > http://www.dfwcfug.org/form_MemberRegistration.cfm
> >
> >
>
> --
> Matt Woodward
> [EMAIL PROTECTED]
> http://www.mattwoodward.com
> ----------------------------------------------------------
> To post, send email to [email protected]
> To unsubscribe:
> http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
> To subscribe:
> http://www.dfwcfug.org/form_MemberRegistration.cfm
>
>
----------------------------------------------------------
To post, send email to [email protected]
To unsubscribe:
http://www.dfwcfug.org/form_MemberUnsubscribe.cfm
To subscribe:
http://www.dfwcfug.org/form_MemberRegistration.cfm