Re: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Michael Grant

What exactly do you mean by processed? Do you mean outputted to the browser?
Wouldn't the code you show end up being before the doctype declaration of an
html page?



On Thu, Sep 15, 2011 at 11:21 AM, Rick Faircloth
r...@whitestonemedia.comwrote:


 !--- [ js version of cf variables ] ---

 cfset   js_sitename  =  application.sitename  /
 cfset   js_website   =  application.website   /
 cfset   js_site_manager_dsn  =  application.site_manager_dsn  /
 cfset   js_client_dsn=  application.client_dsn/

 cfoutput

  script type=text/javascript

   var  js_sitename  =  '#js_sitename#';
   var  js_website   =  '#js_website#';
   var  js_site_manager_dsn  =  '#js_site_manager_dsn#';
   var  js_client_dsn=  '#js_client_dsn#';

  /script

 /cfoutput


 It seems that no matter how I try to do it, either putting js directly
 into an application.cfc or either using a cfinclude in an
 onRequest function, the js can't be processed along with the other
 code in the application.cfc.

 I'm trying to locate all variables for a site in one place (part of
 an MSOC design.

 Rick



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347484
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Rick Faircloth

Hi, Michael...

No, I'm not trying to output anything to the browser, just
establish the variables, in this case the JS global variables
for use throughout the site.

I establish all the CF variables in the application.cfc and
was trying to see if I could accomplish the same thing with the
JS variables.  But trying to process any JS within a .cfc
always just returns the JS script, itself.

It seems like JS can't be processed in a .cfc, or perhaps I'm
missing something.

I've been cfincluding a file that processes the JS variables,
such as those below, as part of the .cfm pages, but was just
trying to see if I could do it once in the application.cfc
in the onRequest section.

Rick

-Original Message-
From: Michael Grant [mailto:mgr...@modus.bz] 
Sent: Thursday, September 15, 2011 11:27 AM
To: cf-talk
Subject: Re: Any way to process this within onRequest in Application.cfc?


What exactly do you mean by processed? Do you mean outputted to the browser?
Wouldn't the code you show end up being before the doctype declaration of an
html page?



On Thu, Sep 15, 2011 at 11:21 AM, Rick Faircloth
r...@whitestonemedia.comwrote:


 !--- [ js version of cf variables ] ---

 cfset   js_sitename  =  application.sitename  /
 cfset   js_website   =  application.website   /
 cfset   js_site_manager_dsn  =  application.site_manager_dsn  /
 cfset   js_client_dsn=  application.client_dsn/

 cfoutput

  script type=text/javascript

   var  js_sitename  =  '#js_sitename#';
   var  js_website   =  '#js_website#';
   var  js_site_manager_dsn  =  '#js_site_manager_dsn#';
   var  js_client_dsn=  '#js_client_dsn#';

  /script

 /cfoutput


 It seems that no matter how I try to do it, either putting js directly
 into an application.cfc or either using a cfinclude in an
 onRequest function, the js can't be processed along with the other
 code in the application.cfc.

 I'm trying to locate all variables for a site in one place (part of
 an MSOC design.

 Rick



 



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347485
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Justin Scott

 It seems that no matter how I try to do it, either putting
 js directly into an application.cfc or either using a cfinclude
 in an onRequest function, the js can't be processed along
 with the other code in the application.cfc.

A few options come to mind...

1) Wrap that output with CFSAVECONTENT, then use CFHTMLHEAD with that
variable and let ColdFusion insert the output into the head section of
the HTML that it output elsewhere.  This will work as long as you're
not using CFFLUSH on CFCONTENT with the reset attribute set to true
further along when processing the page.  This would look like...

cfsavecontent variable=jsVars
script type=text/javascript
var something = #some value#;
/script
/cfsavecontent
cfhtmlhead text=#jsVars# /


2) Use the onRequestEnd() method in Application.cfc and manually
inject into the output stream.  This is similar to the first option,
but allows more control over where you want to inject the content into
the HTML.

cffunction name=onRequestEnd output=yes
cfargument type=string name=targetPage required=true /
cfset var generatedContent = getPageContext().getOut().getString() /
!--- Put the cfsavecontent piece from above here to generate your
output to inject. ---
!--- Write some code here to find where you want to insert it and
modify the generatedContent variable. ---
cfcontent reset=yes type=#variables.returnType#
/cfoutput#generatedContent#/cfoutputcfabort /
/cffunction


3) Use the same CFSAVECONTENT snippet within onRequestStart or
onApplicationStart, whatever makes sense for you, but save it to a
request variable (e.g. request.jsVars) and then output that as part of
your standard header or footer display templates that other pages
might include.


-Justin

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347486
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Justin Scott

 No, I'm not trying to output anything to the browser, just
 establish the variables, in this case the JS global variables
 for use throughout the site.

JavaScript is executed entirely by the browser, so for the browser to
get those variables you will need to include them in the HTML output
stream.  ColdFusion will do all of its processing on the server,
generate the final HTML and send it to the browser, and then the
browser will execute any JavaScript attached to that generated page.
ColdFusion and its CFM/CFC files aren't going to process any of your
JavaScript code internally.


-Justin

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347487
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Rick Faircloth

Thanks for the confirmation, Justin.

That's what I figured...

Rick

-Original Message-
From: Justin Scott [mailto:leviat...@darktech.org] 
Sent: Thursday, September 15, 2011 11:40 AM
To: cf-talk
Subject: Re: Any way to process this within onRequest in Application.cfc?


 No, I'm not trying to output anything to the browser, just
 establish the variables, in this case the JS global variables
 for use throughout the site.

JavaScript is executed entirely by the browser, so for the browser to
get those variables you will need to include them in the HTML output
stream.  ColdFusion will do all of its processing on the server,
generate the final HTML and send it to the browser, and then the
browser will execute any JavaScript attached to that generated page.
ColdFusion and its CFM/CFC files aren't going to process any of your
JavaScript code internally.


-Justin



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347488
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


RE: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Rick Faircloth

Thanks for the approaches, Justin...

I'll give them a try.

Rick

-Original Message-
From: Justin Scott [mailto:leviat...@darktech.org] 
Sent: Thursday, September 15, 2011 11:38 AM
To: cf-talk
Subject: Re: Any way to process this within onRequest in Application.cfc?


 It seems that no matter how I try to do it, either putting
 js directly into an application.cfc or either using a cfinclude
 in an onRequest function, the js can't be processed along
 with the other code in the application.cfc.

A few options come to mind...

1) Wrap that output with CFSAVECONTENT, then use CFHTMLHEAD with that
variable and let ColdFusion insert the output into the head section of
the HTML that it output elsewhere.  This will work as long as you're
not using CFFLUSH on CFCONTENT with the reset attribute set to true
further along when processing the page.  This would look like...

cfsavecontent variable=jsVars
script type=text/javascript
var something = #some value#;
/script
/cfsavecontent
cfhtmlhead text=#jsVars# /


2) Use the onRequestEnd() method in Application.cfc and manually
inject into the output stream.  This is similar to the first option,
but allows more control over where you want to inject the content into
the HTML.

cffunction name=onRequestEnd output=yes
cfargument type=string name=targetPage required=true /
cfset var generatedContent = getPageContext().getOut().getString() /
!--- Put the cfsavecontent piece from above here to generate your
output to inject. ---
!--- Write some code here to find where you want to insert it and
modify the generatedContent variable. ---
cfcontent reset=yes type=#variables.returnType#
/cfoutput#generatedContent#/cfoutputcfabort /
/cffunction


3) Use the same CFSAVECONTENT snippet within onRequestStart or
onApplicationStart, whatever makes sense for you, but save it to a
request variable (e.g. request.jsVars) and then output that as part of
your standard header or footer display templates that other pages
might include.


-Justin



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347489
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Any way to process this within onRequest in Application.cfc?

2011-09-15 Thread Michael Grant

JS is client side. CF is server side. You can use CF to generate the js code
that the browser will run, but you can't actually run it on the server side.
(Caveat is server-side js ofcourse.)


On Thu, Sep 15, 2011 at 11:36 AM, Rick Faircloth
r...@whitestonemedia.comwrote:


 Hi, Michael...

 No, I'm not trying to output anything to the browser, just
 establish the variables, in this case the JS global variables
 for use throughout the site.

 I establish all the CF variables in the application.cfc and
 was trying to see if I could accomplish the same thing with the
 JS variables.  But trying to process any JS within a .cfc
 always just returns the JS script, itself.

 It seems like JS can't be processed in a .cfc, or perhaps I'm
 missing something.

 I've been cfincluding a file that processes the JS variables,
 such as those below, as part of the .cfm pages, but was just
 trying to see if I could do it once in the application.cfc
 in the onRequest section.

 Rick

 -Original Message-
 From: Michael Grant [mailto:mgr...@modus.bz]
 Sent: Thursday, September 15, 2011 11:27 AM
 To: cf-talk
 Subject: Re: Any way to process this within onRequest in Application.cfc?


 What exactly do you mean by processed? Do you mean outputted to the
 browser?
 Wouldn't the code you show end up being before the doctype declaration of
 an
 html page?



 On Thu, Sep 15, 2011 at 11:21 AM, Rick Faircloth
 r...@whitestonemedia.comwrote:

 
  !--- [ js version of cf variables ] ---
 
  cfset   js_sitename  =  application.sitename  /
  cfset   js_website   =  application.website   /
  cfset   js_site_manager_dsn  =  application.site_manager_dsn  /
  cfset   js_client_dsn=  application.client_dsn/
 
  cfoutput
 
   script type=text/javascript
 
var  js_sitename  =  '#js_sitename#';
var  js_website   =  '#js_website#';
var  js_site_manager_dsn  =  '#js_site_manager_dsn#';
var  js_client_dsn=  '#js_client_dsn#';
 
   /script
 
  /cfoutput
 
 
  It seems that no matter how I try to do it, either putting js directly
  into an application.cfc or either using a cfinclude in an
  onRequest function, the js can't be processed along with the other
  code in the application.cfc.
 
  I'm trying to locate all variables for a site in one place (part of
  an MSOC design.
 
  Rick
 
 
 
 



 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347490
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm