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

Cfquery not supported within cfclient in Coldfusion 2018

Community Beginner ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

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!

Views

300

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
LEGEND ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

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-...

 

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-applica...

 

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

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

 

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
Community Expert ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

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

 

 

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
LEGEND ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

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,

 

^ _ ^

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
Community Beginner ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

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.

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
Community Beginner ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

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.

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
Community Expert ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

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/

 

 

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
Community Beginner ,
Jun 28, 2020 Jun 28, 2020

Copy link to clipboard

Copied

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!

 

 

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
Community Expert ,
Jun 28, 2020 Jun 28, 2020

Copy link to clipboard

Copied

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.

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
Community Expert ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

Hi marius_luc,

I have good news. I got it to work.

 

The steps are:

1) Open the Server Settings page of the ColdFusion Administrator. Scroll down to Mobile. Enter a value for the mobile secret key, for example, 0612345678, and click on Save. (Don't use the key that ColdFusion generates. I did that and it never worked. In fact, I have submitted a bug report.) 

2) Open the Application.cfc file of your application. In the section where you declare this scoped variables, add the line

 

<cfset this.mobileSecretKey="0612345678">

 

3) Run the CFM page containing the code:

 

<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>

 

 

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
Community Beginner ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

Hi,

Thank you very much for this solution.....but is working in web-browser....if I want to compile the code using "Run Debug Project" from Coldfusion Builder 2018, I see this error:

"C:\ColdFusionBuilder2018\ColdFusion\cfusion\wwwroot\prj4\index.cfm,An exception has occurred in the processing of CFClient code : ''

This error come from cfclientsettings.

Do you have idea to fix this issue and compile the code with succesfully?

Thank you very much!

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
Community Expert ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

What are the errors appearing in application.log, exception.log and coldfusion-out.log? Please share with us the errors in full.

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
Community Beginner ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

No errors anymore (I have restarted the server).

I run the code in web-browser and is working OK

http://mobiledev-com.server-ez-sos-com.vps.ezhostingserver.com/MobileApps/cfqueryprj/

but when I try to compile the code and create the APK file (then install it to my phone) using Coldfusion Builder 2018, the screen is emtpy, show me nothing.

 

<cfclientsettings mobileserver="http://cf.server-ez-sos-com.vps.ezhostingserver.com:8500" enabledeviceapi="false">
<cfclient>
<cfquery name="q1" datasource = "applustigdmx" type="server">
select * from collection
</cfquery>
<cfoutput>#serializeJSON(q1)#</cfoutput>
</cfclient>

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
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Now I fail to understand what you're trying to do. Why would you want to dump a query in a mobile application? 

 

Anyway, the above code is for the server. Since, as you say, the server code is now working, it means your original question has been answered.

 

If you view the source of the HTML page (of the server code) you will see the Javascript version of the code. You can of course run that as a mobile application. In any case, if you now have a question about using Coldfusion Builder 2018 to compile code and create the APK file (then install it to your phone), I will suggest that you start a new thread in the CFBuilder forum.

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
Community Beginner ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Hi,

I changed a bit the code,

so here http://mobiledev-com.server-ez-sos-com.vps.ezhostingserver.com/MobileApps/cfqueryprj/ all is OK

but if I compile and generate APK file, on my phone I see nothing. I used the below code:

 

<cfclientsettings mobileserver="http://cf.server-ez-sos-com.vps.ezhostingserver.com:8500" enabledeviceapi="false">
<cfclient>
<cfquery name="q1" datasource="applustigdmx" type="server">
select * from collection where collectionID in (3,5)
</cfquery>

<cfset varjson = serializeJSON(q1) >

<cfset cfData=DeserializeJSON(varjson)>

<cfloop from="1" to="#arrayLen(cfData.DATA)#" index="i">

<cfset COLLECTIONID = cfData.DATA[i][1]>
<cfset COLLECTIONNAME = cfData.DATA[i][2]>
<cfset COLLECTIONDESCRIPTION = cfData.DATA[i][3]>
<cfset COLLECTIONDESCLONG = cfData.DATA[i][4]>
<cfset COLLECTIONIMG = cfData.DATA[i][5]>
<cfset COLLECTIONDISALLOWDISCOUNT = cfData.DATA[i][6]>

<cfoutput>#i#) COLLECTIONID: #COLLECTIONID# | COLLECTIONNAME: #COLLECTIONNAME# <br /></cfoutput>

</cfloop>

</cfclient>

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
Community Expert ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

Hi marius_luc,

Did you read my last post? 

Your original question has been answered. So, mark this thread as answered.

 

Then ask a new question - on how to use ColdFusion Builder to convert cfclient code to mobile APK - in the Builder section. Otherwise, it gets confusing.

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
LEGEND ,
Jun 29, 2020 Jun 29, 2020

Copy link to clipboard

Copied

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,

 

^ _ ^

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
Community Expert ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

LATEST

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)

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