Skip to main content
marius_luc
Participating Frequently
June 26, 2020
Question

Cfquery not supported within cfclient in Coldfusion 2018

  • June 26, 2020
  • 6 replies
  • 586 views

Hi, I have a problem with cfquery tag inside cfclient tag for Coldfusion 2018.

Cfquery is working outside cfclient tag...but inside cfclient is not working

this code is not working:

<cfclient>

<cfquery name="q1" datasource = "storebooksdmx">
select * from collection
</cfquery>
<cfoutput>#serializeJSON(q1)#</cfoutput>

</cfclient>

 

but this code is working ok:

 

<cfquery name="q1" datasource = "storebooksdmx">
select * from collection
</cfquery>
<cfoutput>#serializeJSON(q1)#</cfoutput>

 

Any help please?

Thanks!

    This topic has been closed for replies.

    6 replies

    WolfShade
    Legend
    June 29, 2020

    Well, I'll admit that I'm biased when it comes to CF Builder.  I don't like it.  Not one bit.

     

    There are several other IDEs that are superior, IMHO, to CFB.  Even DreamWeaver minus CF support is better than CFB.

     

    If CFB won't do what you want without the CFCLIENT tag, it's holding you back.  Use a better IDE.

     

    That being said, and contrary to what BKBK has stated, your best course of action is to learn Javascript and code what you want, getting away from CFCLIENT.  It will serve you better, both now and in the future.  CFCLIENT is one of those tags that should be avoided due to lack of updates, and future changes could wreck what you are attempting to do.

     

    V/r,

     

    ^ _ ^

    Charlie Arehart
    Community Expert
    Community Expert
    July 16, 2020

    I'd like to add a few points, some supporting the most recent comments (why you may want to move away from the CF Mobile feature set added in CF11), some pointing to an alternative, and yet also sharing some resources to help you, Marius, if you are preferring to plug along.

     

    First, let me note that Adobe has even acknowledged (in public presentations on the past and future of CF) that the mobile strategy introduced in CF11 (and CFB 3) was not...let's say, their best idea. It's not yet identified as a deprecated (in the CF2018 doc on deprecated features), but you can hear the disdain toward it from others here (though some  is directed at CFB more generally--and as that's just the way Adobe chose to implement their mobile strategy for integrating CF and that cfclient and related tags, it's what you must use if you are going to soldier on for some reason).

     

    And to that point, Marius, what resources have you used to help get you started? If you may (like many) be reading only the CFML Reference, well, that's like trying to learn to speak a language from a dictionary--definitely not efficient. Have you seen the 72-page section on the CF Mobile development feature? When it came out in CF11, it was its own manual and in PDF form (still available):

     

    http://help.adobe.com/archive/en_US/coldfusion/11/ColdFusion_MobileAppDevelopment.pdf 


    Adobe no longer created PDFs for the CF Docs after CF11, but the info is also online here:


    https://helpx.adobe.com/coldfusion/mobile-application-development.ug.html

     

    Finally, as for moving on to a better mobile solution, I'll note that next week on the Online ColdFusion Meetup (coldfusionmeetup.com), we will be having a presentation on a free and mature-yet-active javascript-based mobile development platform, called NativeScript (nativescript.org). More on the meeting (and yes, it will be recorded) at 
    https://www.meetup.com/coldfusionmeetup/events/271844332/

    /Charlie (troubleshooter, carehart. org)
    marius_luc
    Participating Frequently
    June 28, 2020

    Hi, thank you very much for advices.

    I run this 

    <cfclientsettings mobileserver="http://127.0.0.1:8500" enabledeviceapi="false">
    <cfclient>
    <cfquery name="q1" datasource = "storebooksdmx" type="server">
    select * from collection
    </cfquery>
    <cfoutput>#serializeJSON(q1)#</cfoutput>
    </cfclient>
    but show me a blank page http://127.0.0.1:8600/workspace/marius9/index.cfm (here is Coldfusion Builder 2018 at port: 8600), also a blank page when installed the .apk file to my phone.

    Coldfusion 2018 is installed here: 127.0.0.1:8500

    Coldfusion Builder 2018 here: 127.0.0.1: 8600

     

    maybe cfquery within cflclient not working for Local.....maybe I must to install for Remote?

     

    I need a connection to local and/or remote datasource to extract data for use in mobile development app.

     

    Thank you!

     

     

    BKBK
    Community Expert
    Community Expert
    June 28, 2020

    Sorry to hear that. With those settings it should work.

    Please report a bug. Let us know after you do. We shall then vote to get the bug fixed quickly.

    marius_luc
    Participating Frequently
    June 26, 2020

    I'm interested in Mobile application development using Coldfusion 2018/ColdFusion Builder 2018 (Cordova).

    If I want to compile the source code using Coldfusion Builder, is required to include "<cfclient>" tag.....if I remove <cfclient> the Coldfusion Builder will not compile the project and will show errors.

    is there any other solution? or other way to develop mobile app in Coldfusion?

    Thanks for advices.

    BKBK
    Community Expert
    Community Expert
    June 27, 2020

    Hi marius_luc,

    As WolfShade and Dave have pointed out, cfclient quickly went out of date. Just like other client user-interfaces in ColdFusion, such as cfdiv, cfgrid, cflayout and so on. Nevertheless, I do believe we can make an exception for cfclient.

     

    Cfclient can be useful in mobile application development. Especially as it can convert sophisticated ColdFusion code into its Javascript equivalent, providing you with a ready-made mobile API right there. As an achievement, this remains a tour de force by Adobe's ColdFusion Team.

     

     @marius_luc, when you say,

    "Cfquery is working outside cfclient tag...but inside cfclient ...this code is not working"

    it makes me think there is a misunderstanding. Cfquery is CFML code, and is not supposed to work "inside cfclient". 

     

    You should consider cfclient to be a translator. If you gave some Japanese text to a Japanese-to-English translator, you wouldn't expect it to read the text back to you in Japanese. You would expect it to read the English translation of the text.

     

    So, too, with cfclient. It does not run the CFML code. Instead, it converts the CFML code into the Javascript equivalent. The result can be that ColdFusion expects you to supply the database connection settings for the client API environment. So you have to tell ColdFusion which mode you expect the results to be in.

     

    To distinguish between the client(Javascript) and server(CFML), use

    1) the cfclientsettings tag

    2) the type attribute in cfquery

     

    Your code will then be something like:

     

     

     

    <cfclientsettings  mobileserver="http://your-server:port-number"  enabledeviceapi="false">
    <cfclient>
    <cfquery name="q1" datasource = "storebooksdmx" type="server">
    select * from collection
    </cfquery>
    <cfoutput>#serializeJSON(q1)#</cfoutput>
    </cfclient>

     

     

     

    Yet another reference:

    https://coldfusion.adobe.com/2019/09/support-server-side-tags-functions-cf-mobile-development/

     

     

    WolfShade
    Legend
    June 26, 2020

    Yeah, just because the documentation states that CFQUERY is supported within a certain tag (like CFCLIENT) doesn't necessarily mean that it's going to work the way you expect it to, anyway.

     

    HTH,

     

    ^ _ ^

    marius_luc
    Participating Frequently
    June 26, 2020

    I'm interested in Mobile application development using Coldfusion 2018/ColdFusion Builder 2018 (Cordova).

    If I want to compile the source code using Coldfusion Builder, is required to include "<cfclient>" tag.....if I remove <cfclient> the Coldfusion Builder will not compile the project and will show errors.

    is there any other solution? or other way to develop mobile app in Coldfusion?

    Thanks for advices.

    Community Expert
    June 26, 2020

    Yeah, listen to @WolfShade and don't use CFCLIENT. It's not good for modern applications. JavaScript standards change a lot faster than server-side code requirements. In general, you wouldn't want to embed a CFQUERY inside presentation logic anyway, and CFCLIENT is definitely presentation logic.

     

    Dave Watts, Eidolon LLC

     

     

    Dave Watts, Eidolon LLC
    WolfShade
    Legend
    June 26, 2020

    Hello, Marius,

     

    As someone who has worked with ColdFusion since 2000, I am leery of something that is supposed to convert CF-code into Javascript and HTML.  But, in case you haven't found it, there is the support page documentation for CFCLIENT:

    https://helpx.adobe.com/coldfusion/developing-applications/developing-cfml-applications/client-side-cfml-for-mobile-development.html

     

    That being said, it doesn't surprise me that you are having an issue with CFCLIENT, if for no reason other than Adobe is known for using outdated Javascript libraries for things like CFFORM and other RTF options.  So, one can reasonably assume that the JS library used for CFCLIENT is also outdated.  My assumption could be incorrect; I am not part of the dev team that is releasing CF Server.  But it would not surprise me.


    So, please ask yourself if using CFCLIENT is absolutely necessary for what you are attempting to do.  If you can do it without CFCLIENT, I'd recommend that as your course of action.

     

    I know that this isn't the advice you were looking for.  Best wishes in your search for an answer.

     

    V/r,

     

    ^ _ ^

     

    UPDATE:  Have you looked in the CF logs for error messages?  Or are any errors being reported onscreen or in console?

     

    UPDATE2:  I found this SO thread from 2014.  Please read:

    https://stackoverflow.com/questions/23173431/is-it-worth-of-learning-cfclient-api-for-mobile-application-development

     

    UPDATE3:  And the hits just keep coming.  Very good reading, here:

    http://blog.adamcameron.me/2013/10/cfclient.html