Yep I'll second Andrew on this one,

For a short hand, many people just create a var'd structure in the top of
each function and then reference everything else into the structure,
something like this.

<cffunction ....>

        <cfset var LOCAL = structNew() />

        <cfset LOCAL.this = "somthing" />
        <cfset LOCAL.that = "somthingelse" />

        <cfquery name="LOCAL.query" datasource="myDSN">
        </cfquery>

</cffunction>

It saves having to var every single variable yourself.

Rob



-----Original Message-----
From: Andrew Scott [mailto:[EMAIL PROTECTED] 
Sent: 02 May 2007 15:03
To: CF-Talk
Subject: Re: Problem Using CFC Within IFrame

Remember to also var you function variables too, your cfquery in the
function is not var'ed that will cause problems later.

On 5/2/07, Anne Porosoff <[EMAIL PROTECTED]> wrote:
>
> Ok, turns out I'm an idiot.  I did some more digging around and apparently
> the problem was originating from another CFC that I was calling from the
> first CFC.  Once I corrected that problem, everything worked
> great.  Nonetheless, thanks for looking into this one for me.
>
> --Anne
>
> > Not a problem, let me know if the below helps:
> ------------>
> ---------------------------------------------------------------------
> > form.cfm:
> ------------>
> ---------------------------------------------------------------------
> > <cfset vPageID = 1>
> >
> > <script language="javascript">
>
> > function addNewItem(){
>
> > var curobj = document.myForm;
>
> > var queryString = "?pageID="#vPageID#" +
>
> > "&itemName=" + curobj.itemName.value;
>
> >
>
> > window.frames['itemfrm'].location = 'add_new_item.cfm' + queryString;
>
> > }
> > </script>
> >
> > <iframe style="width:0;height:0;margin:0;padding:0;display:none;"
> > id="itemfrm" name="itemfrm" src=""></iframe>
> >
> > <form name="myForm" action="form.cfm">
>
> > Add Item: <input type="text" name="itemName" />
>
> > <input type="button" value="Add New Item" onclick="addNewItem()" />
> > </form>
> >
> ------------>
> ---------------------------------------------------------------------
> > add_new_item.cfm
> ------------>
> ---------------------------------------------------------------------
> > <cfset itemData = createObject('component','itemDataMethods').
> > init(pageID = url.pageID)>
> >
> > <cfoutput>
>
> > #itemData.addToItems(itemName = url.itemName)#
> > </cfoutput>
> >
> ------------>
> ---------------------------------------------------------------------
> > itemDataMethods.cfc
> ------------>
> ---------------------------------------------------------------------
> > <cfcomponent>
>
> > <cffunction name="init">
>
> > <cfargument name="pageID" required="true">
> >
>
> > <cfscript>
>
> > variables.pageID = arguments.pageID;
>
> > </cfscript>
> >
>
> > <cfreturn this>
>
> > </cffunction>
> >
>
> > <cffunction name="addToItems"
>
> > access="public"
>
> > returntype="void">
>
> > <cfargument name="itemName" required="true">
> >
>
> > <cfquery name="addItem" datasource="myItemsDB">
>
> > insert into myItemsTable
>
> > ( pageID,
>
> > itemName
>
> > )
>
> > values ( <cfqueryparam value="#variables.pageID#"
> > cfsqltype="CF_SQL_VARCHAR">,
>
> > <cfqueryparam value="#arguments.itemName#"
> > cfsqltype="CF_SQL_VARCHAR">
>
> > )
>
> > </cfquery>
>
> > </cffunction>
> > </cfcomponent>
> ---------------->
> ---------------------------------------------------------------------
> >
> > This is a very basic overview of the scripts I'm working with and
> > hopefully it gives you a better idea of what I'm working with.
> > However, if you have any questions, please let me know.  Thanks in
> > advance for your help.
> >
> > --Anne
> >
> > >Anne,
> > >I don't know of any specific problems with the technique that you
> > are
> > >trying to use.  I would suggest trying to make a really simple demo
> > of
> > >what you are trying to achieve for demonstration purposes, and post
> > that
> > >code to the list so we can see all the moving parts of what is going
> > on,
> > >then we might be able to give you some more feedback.
> > >
> > >Rich
> Kroll
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. 
Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:276757
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to