Here are my conclusions and hopefully someone can figure this out for
me. Is there anything special I have to do server side to be able to
call a cfc?
When I do this
<script type="text/javascript">
var XML_URL =
"../FunctionPages/Employers.cfc?method=GetEmployerResults";
//create a basic Spry DataSet
var dsEmployers = new Spry.Data.XMLDataSet(XML_URL, "dataset/row", {
useCache: false });
//create a page-enabled view of the Spry DataSet
var pvEmployers = new Spry.Data.PagedView(dsEmployers, { pageSize: 12
});
</script>
I get a coldfusion time out error and the spry does not load the data.
Here is my CFC
<CFFUNCTION name="GetEmployerResults" access="remote" returntype="void"
output="false">
<CFARGUMENT name="EmployerName" default="" />
<CFQUERY datasource="#request.dsource#" name="EmployerQry">
SELECT rtrim(FirstName) as FirstName, rtrim(LastName) as
LastName, rtrim(EmailAddress) as EmailAddress
FROM AMP_Employers
WHERE EmployerID > 0
</CFQUERY>
<cfset toXML = createObject("component", "toXML")>
<cfset EmployerXML = toXML.queryToXML(EmployerQry, "dataset",
"row")>
<cfset parsedEmployerXML = xmlParse(EmployerXML) >
<cfcontent type="application/xml; charset=UTF-8">
<cfreturn parsedEmployerXML >
</CFFUNCTION>
When I do this below (switch the cfc page to a cfm page) it runs
perfectly.
<script type="text/javascript">
var XML_URL = "../FunctionPages/Employers.cfm";
//create a basic Spry DataSet
var dsEmployers = new Spry.Data.XMLDataSet(XML_URL, "dataset/row", {
useCache: false });
//create a page-enabled view of the Spry DataSet
var pvEmployers = new Spry.Data.PagedView(dsEmployers, { pageSize: 12
});
</script>
Here is my cfm file
<CFQUERY datasource="#request.dsource#" name="EmployerQry">
SELECT rtrim(FirstName) as FirstName, rtrim(LastName) as LastName,
rtrim(EmailAddress) as EmailAddress
FROM AMP_Employers
WHERE EmployerID > 0
</CFQUERY>
<cfset toXML = createObject("component", "toXML")>
<cfset EmployerXML = toXML.queryToXML(EmployerQry, "dataset", "row")>
<cfset parsedEmployerXML = xmlParse(EmployerXML) >
<cfcontent type="application/xml; charset=UTF-8">
<CFOUTPUT>#parsedEmployerXML#</CFOUTPUT>
-----Original Message-----
From: Chad McCue [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 12:56 PM
To: CF-Talk
Subject: RE: Using Spry to Page forward and backward through data
When I try to put my returntype of my function to XML it goes into an
very long loop and comes back with XML error saying the top element
needs to be defined. Any ideas?
-----Original Message-----
From: Raymond Camden [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 12:03 PM
To: CF-Talk
Subject: Re: Using Spry to Page forward and backward through data
I'm afraid you lost me. You want to return the XML as a variable that
Spry can read? Well you know that client side code can't read CF code,
right? If your question is - can I include the XML data itself IN the
page, then yes, you can. Spry doesn't have to make a HTTP request to get
the XML. See this URL:
http://labs.adobe.com/technologies/spry/samples/data_region/XMLStringSam
ple.html
On 4/12/07, Chad McCue <[EMAIL PROTECTED]> wrote:
>
> Is there now way of returning XML in a variable and have spry read it?
> I need the customer to search and return results before the page that
> the spry is located on is displayed.
>
> -----Original Message-----
> From: Raymond Camden [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 12, 2007 9:58 AM
> To: CF-Talk
> Subject: Re: Using Spry to Page forward and backward through data
>
> In my presentation last night I showed multiple examples of pointing
> Spry to a CFM page. I'm assuming the recording will be up soon at
>
> http://www.cfugtoronto.org/
>
> On 4/12/07, Massimo Foti <[EMAIL PROTECTED]> wrote:
> > > My code works if I directly call the XML file, I am trying to
> > > avoid this and I want to pass the XML file back as a variable, I
> > > don't want to save the XML file to webroot folder.
> >
> > There is no need to save the XML anywhere, the examples use static
> > .xml files, but you can just point them to a .cfm file that output
> > the
> XML.
> >
> > For a complete application see:
> > http://www.massimocorner.com/spry/dynamic_spry.zip
> >
> >
> > Here you can see a very basic example of how to use CF and a
> > database to drive one of Sprys demos:
> > http://www.adobe.com/devnet/dreamweaver/articles/edit_data_in_ajax.h
> > tm
> > l
> >
> > ----------------------------
> > Massimo Foti, web-programmer for hire Tools for ColdFusion and
> > Dreamweaver developers:
> > http://www.massimocorner.com
> > ----------------------------
> >
> >
> >
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Macromedia ColdFusion MX7
Upgrade to MX7 & experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion?sdid=RVJW
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275094
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4