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

Calling custom CF tag from javascript

New Here ,
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

Could someone please help me by posting some psuedo code to call a custome cf tag from javascript? I am feeling pretty dumb but can't figure it out...

Thanks bunches!
Va.
TOPICS
Advanced techniques

Views

876

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

correct answers 1 Correct answer

LEGEND , Jul 06, 2007 Jul 06, 2007
Have the button submit a form to another cf page that calls the custom tag. If you don't want to actually leave the page you are on, put the target page into a little bitty iframe.

Votes

Translate

Translate
LEGEND ,
Jul 06, 2007 Jul 06, 2007

Copy link to clipboard

Copied

Javascript runs on the client. Cold fusion runs on the server. There are ways around this, but it depends on how you are starting the javascript and what the custom tag does.

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

Copy link to clipboard

Copied

Press button, call tag to export to excel... so client, server shouldn't be an issue... :-)

thanks,
Va.

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

> Press button, call tag

Where is the button? Where is the tag?

The button is activated by the user of the client browser, and any your
JavaScript event handler on that is being run by the client browser.

The tag is residing on the CF applicationserver, and requires to be
executed *by* that server.

There is never any connection between the client browser and the CF server.
There is the network, a web server, and a webserver/CF gateway lying
between the client browser and the CF application server; and the two NEVER
directly interact.


> so client, server shouldn't be an issue

I think you need to stop and think about where all the components in this
process reside, and what executes them.

And then you will see that any activity on the browse side of things needs
to call back to the server side of things to get CF to run its custom tag
(or any other CF code, for that matter).

--
Adam

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

Copy link to clipboard

Copied

Sorry, I wasn't trying to sound obnoxious... typed before I thought!

Actually yeah, guess I wasn't thinking about it... we'll do a javascript function to feed back into the cf page. And I actually think we want to leave the page.. into a completely new excel file. I am kind of a third party so I only got asked and couldn't think it through, but that helped... 🙂 I had never done it with a custom tag, just fed the page back into itself with the cfcontent...

Thanks,
Va.

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

Copy link to clipboard

Copied

No worries: an awful lot of people don't initially "get" the sequence of
events which take place to get CF-driven HTML down to the web browser.

That's not to say you can't do what you want to do, I should think.

One can make calls back to the server "in the background" of the browser
page, using one of a few techniques. The one with the best buzzword is
"AJAX". It's perhaps worth googling about the place for some info on that.
It's JavaScript technology, not CF technology, so these forums aren't the
best place for discussion on that. I'm sure there'll be plenty of AJAX
forums out there...

--
Adam

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

Copy link to clipboard

Copied

LATEST
> ... call a custome cf tag from javascript...
> ...Press button, call tag to export to excel ...

Doing it with Javascript defeats the purpose of a custom tag. A custom tag is your own custom Coldfusion tag, hence to be used as a tag in a cfm or cfc page. I would instead have Javascript open the cfm page directly, thus

<html>
<head>
<title>Opening excel page with Javascript</title>
<script type="text/javascript">
function openIt () {
window.open("excelExport.cfm","_blank","height=300,width=500,status=yes,menubar=yes,resizable=yes,scrollbars=yes");
}
</script>
</head>
<body>
<FORM>
<BUTTON name="btn" onclick="openIt();">open it</BUTTON>
</FORM>
</body>
</html>


excelExport.cfm
================
<cfheader name="Content-Disposition" value="attachment; filename=testPage.xls">
<cfcontent type="application/vnd.msexcel" file="C:\CFusionMX7\wwwroot\testPage.xls">

Here follows code that does it the custom tag way. You will get the feel of redundancy immediately.



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

Have the button submit a form to another cf page that calls the custom tag. If you don't want to actually leave the page you are on, put the target page into a little bitty iframe.

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