PDA

View Full Version : Coldfusion doesn't work here...



RonaldX
30 Mar 2011, 10:02 AM
Hi,

First I watched the video (http://experts.adobeconnect.com/p99437705/?launcher=false&fcsContent=true&pbMode=normal) about connecting Sencha and Coldfusion through JSON calls but found it a bit cumbersome.

So I tried to do the following with the given carousel example of sencha touch, which is quite simple but didn't work:

...
var carousel1 = new Ext.Carousel({
defaults: {
cls: 'card'
},
items: [{
html: '<h1>Carousel - <cfoutput>#now()#</cfoutput></h1><p>Hello World.</p>'
},
{
title: 'Tab 2',
html: '2'
},
{
title: 'Tab 3',
html: '3'
}]
});
...

It renders as "Carousel - #now()#", hence the Coldfusion compiler did not recognize its markup. :(
Usually I can embed CF markups within JScript though.
(YES, I did rename the index.htm to index.cfm first :)

Is there any way to embed CF tags into ie. the "html:" branch of Sencha Touch?

Any tips appreciated.

Ronald

dawesi
30 Mar 2011, 6:13 PM
It renders as "Carousel - #now()#", hence the Coldfusion compiler did not recognize its markup. :(
Usually I can embed CF markups within JScript though.
(YES, I did rename the index.htm to index.cfm first :)

Is there any way to embed CF tags into ie. the "html:" branch of Sencha Touch?

Ronald

The issue isn't ColdFusion or javascript (which jscript is MS's version of).

Your webserver doesn't process .js files with ColdFusion, PHP, Ruby or any other language. (unless you tweak it). It sends them straight to the browser like a text file.

To generate you need to change the filename from myjavascript.js to myjavascript.js.cfm or myjavascript.cfm in your script tag so that ColdFusion handles the request.

eg:




<script src="/js/mycarousel.js.cfm" type="text/javascript"></script>

<instead of>

<script src="/js/mycarousel.js" type="text/javascript"></script>


the extra .js before the .cfm is a handy metadata item (optional) that let's you and other coders know that this is in fact a javascript file that needs to be parsed by ColdFusion.

Out of interest what ColdFusion engine are you using? Adobe ColdFusion or a free OpenSource cfml engine? (Railo/Open BlueDragon/Smith)

Cheers,
Dawesi

RonaldX
31 Mar 2011, 4:23 AM
Thanks for the tip, Dawesi - it works! :-)

BTW: If somebody wants to use my example, be sure to correct the CF tag to ie. "#DateFormat(now(),"MM.DD.YYYY")#", since otherwise it won't work!

I am using Adobe CF version 8 on CentOS for production and Windows for dev.