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

Function call

Guest
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

I need to call a function and pass a query to it by clicking a button (or link).
What is the best way to do it?

The function actually converts the passed query into excel format and displays it.


Any suggestions welcome
TOPICS
Advanced techniques

Views

388

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 ,
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

Do it the same way you call any other function. The fact that your argument will be a query shouldn't be an issue, just make sure you declare it as such in your cfargument tag.

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
Guest
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

How do I do it by clicking a button? The query is only available on the same page as the button.

Thnx

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 ,
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

The query is only available on the same page as the button.

No it's not. By the time a button has been displayed the CF engine has
forgotten about the query unless you did something to preserve it in a
persistent scope.

You need to keep the difference between the server and client seperate
here and understand what happens from request to request and that by
default the web is a stateless environment.

The simplest way to do what you are wanting is to have the button make
the same request the built the original page with a simple URL parameter
that means "return CSV" and then the ColdFusion template called for the
request will build the desired file and return it as the response the
this new request.

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
Guest
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

Well, thank you for the lesson on the web stateless environment.
My whole point was to at least pass the query that IS available to the calling page...


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 ,
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

LATEST
My whole point was to at least pass the query that IS available to the
calling page...

But that statement does not work in a stateless environment. The query
is NOT available to be passed.

1) A request was made to web server.

2) Web server determines request is for ColdFusion, passes request to CF.

3) CF Process request creating and using query and builds response.

4) Response is returned to web server, CF clears all data for garbage
collection and goes on to next request.

5) web server passes response to client.

6) client renders response and waits for user interaction.

7) user activates button, new request is sent to web server.

8) It all starts over again.

There is no "query" anymore by the time a user sees a button and can
click on it, unless something is done to save it in a persistent scope
so that it can be used from request to request. And even then, a new
request must be made to do something with the query.

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