• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

SQL to XML for AJAX

New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Greetings,

I have been a CFer for a while and am dipping my toe into the Spry/AJAX world. What I am attempting to do is not only learn Spry/AJAX to develop RIAs, but go down the AIR path. I do nto know if this is the right place to ask this, but here goes...

I hav a SQL database that contains the data for my app. If I were simply developing a CF app, I would just use a basic cfquery statement. In order to get an XML file out of the SQL database for my Spry/AJAX app, I built a file using the cfxml tag. It worked great, but my only concern is the refreshing of the XML file from the SQL database. What is the standard best practive to get this done? Do I call a CFschedule tag? Call the cfxml tag to run or what? I want to make sure my end users have the most upto date XML data as possible.

Any guidance would be appreciated.

Thanks in advanced.

~Clay
TOPICS
Advanced techniques

Views

589

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Hi,

I would suggest you to use your .CFM file to output xml data dynamically to clients. You can use use <cfcontent type="text/xml" reset="yes"> to specify the content type of your .CFM file as XML. This way your xml is a dynamic one, as opposed to a static xml.

Do not use <cfsavecontent> to write it to disk - disks operations are always slower. Simply, send the data back to client. For caching purpose, consider using cachedWithin attribute of <cfquery> tag - this will take care of your page's performance.

Sam
Adobe Certified Flash and
Advanced ColdFusion Developer

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

That sounds like a good idea. Do you have any examples that I can see please?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Don't have any thing to share. You start coding, if you stumble get back with your issue.

Your page would be pretty simple and straightforward:

<cfcontent type="text/xml" reset="yes" />
<?xml version="1.0" encoding="utf-8"?>
<root>
<writeanyxmlhere />
</root>
<cfabort />

Use of <cfabort> would be "required" if your application has footers.

Sam
Adobe Certified Flash and
Advanced ColdFusion Developer

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2008 Jun 06, 2008

Copy link to clipboard

Copied

Allow me to explain some more. I can generate the XML with CF. What my question is...how do I have the CF code generate the XML when the app is instantiated using Spry? I want to make sure the XML is as up to date from the SQL database as possible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 09, 2008 Jun 09, 2008

Copy link to clipboard

Copied

LATEST
You call a cfc to populate your spry dataset, eg see attached code

The cfc would use cfquery as per usual, but you just create your xml on the fly, see attached code

Then parse and convert the xml to a string, then return the xml string, see attached code

Thus you now have a spry dataset

Ken

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation