Adobe Dreamweaver Forums



Last 10 THreads :         Event listener (Last Post : NedWebs - Replies : 1 - Views : 2 )           »          action script for button (Last Post : melanro - Replies : 4 - Views : 10 )           »          Problems with variables (Last Post : Rob Dillon - Replies : 1 - Views : 2 )           »          Trouble with SQL Query Tool on Leopard (Last Post : pdenlinger - Replies : 4 - Views : 5 )           »          Sefl-signed ssl certificate not possible? (Last Post : sysfor - Replies : 2 - Views : 8 )           »          Adding database RDS Login Dreamweaver 8 Coldfusion 8 (Last Post : Daverms - Replies : 3 - Views : 5 )           »          set width of adv. datagrid according to image width. (Last Post : Devsachin - Replies : 0 - Views : 1 )           »          Dreamweaver cs4 (Last Post : Murray *ACE* - Replies : 9 - Views : 10 )           »          Centering a site using layers in browser window (Last Post : Murray *ACE* - Replies : 3 - Views : 4 )           »          Beginner help - PUT confusion (Last Post : Murray *ACE* - Replies : 7 - Views : 8 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags:



Reply
  #1 (permalink)  
Old 10-08-2008, 07:40 PM
ProjectedSurplus
 
Posts: n/a
Diggs:
Default Application Variables vs Request Variables

I've read a number of forums and cf books but they seem to contradict each
other.

To me it seems better to put say the datasourcename into the application
variable -- but I dont seem able to use #APPLICATION.varname# in my pages
(cf8). Am I doing something wrong?

Alternatively #REQUEST.varname# I can use no problem but this to me is
requiring the cf server to do unnecessary extra work (ie before each page
request) is it not?

Thanks in advance,



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-08-2008, 07:51 PM
Ian Skinner
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

> To me it seems better to put say the datasourcename into the application
> variable -- but I dont seem able to use #APPLICATION.varname# in my pages
> (cf8). Am I doing something wrong?
>


Must be, because I use application variable all the time in my CF8 CFML
code and have been since I started using ColdFusion with version 4.5.

But since I do not know what you are doing, I can say much about *why*
you are having difficulty using application variables in your code.
Reply With Quote
  #3 (permalink)  
Old 10-08-2008, 08:31 PM
Adam Cameron
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

> I've read a number of forums and cf books but they seem to contradict each
> other.
>
> To me it seems better to put say the datasourcename into the application
> variable
>
> Alternatively #REQUEST.varname#


Some "confusion" arose on this sort of topic in old versions of CF (prior
to 6) in that they were very buggy when it came to doing even simple
operations with shared-scope variables (server, application, session). The
solution to this was to <cflock> every single access to this sort of
variable. What a pain in the bum that was. As such, people shunned them -
and adviseably so - for things like DSNs, because it would mean either
locking the entire query (bad), or copying the application-scoped DSN into
some other request-specific scope (most often the request scope).

However that's been fixed since CFMX6.

Variables that are global to the application should be put in the
application scope. Variables that are global to a request should be put in
the request scope. Almost always, a DSN is going to be global to the
application, so application.dsn is the better fit there.


> -- but I dont seem able to use #APPLICATION.varname# in my pages
> (cf8). Am I doing something wrong?


Quite possibly. But how do you expect us to answer that sensibly without
you showing us the relevant code? Guess? I therefore guess that - yes -
you are definitely doing something wrong ;-)


> I can use no problem but this to me is
> requiring the cf server to do unnecessary extra work (ie before each page
> request) is it not?


Correct. But the specifics of this DSN thing aside, a bigger concern is
getting this application scope working. Because it should (work).

--
Adam
Reply With Quote


  #4 (permalink)  
Old 10-08-2008, 09:01 PM
ProjectedSurplus
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

<cfcomponent output="false">


<cfscript>
//the application name (should be unique)
THIS.name = "olo";
//how long the application variables persist
THIS.applicationTimeout = createTimeSpan(0,2,0,0);
//define whether client variables are enabled
THIS.clientManagement = true;
//where should we store them, if enabled?
THIS.clientStorage = "cfClientVariables"; //cookie||registry||datasource
//define where cflogin information should persist
THIS.loginStorage = "session"; //cookie||session
//define whether session variables are enabled
THIS.sessionManagement = true;
//how long the session variables persist?
THIS.sessionTimeout = createTimeSpan(0,0,20,0);
//define whether to set cookies on the browser?
THIS.setClientCookies = true;
//should cookies be domain specific
//i.e. *.domain.com or www.domain.com
THIS.setDomainCookies = false;
//should we try to block cross-site scripting?
THIS.scriptProtect = false;
//should we secure our JSON calls?
THIS.secureJSON = false;
//use a prefix in front of JSON strings?
THIS.secureJSONPrefix = "";
//used to help ColdFusion work with missing files
//and directory indexes. tells ColdFusion not to call
//onMissingTemplate method.
THIS.welcomeFileList = "";
//define custom coldfusion mappings.
//Keys are mapping names, values are full paths
THIS.mappings = structNew();
//define a list of custom tag paths.
THIS.customtagpaths = "";
</cfscript>


<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfset APPLICATION.companyName = "OnlineOffice.com">

<cfreturn true />
</cffunction>

Reply With Quote
  #5 (permalink)  
Old 10-08-2008, 09:13 PM
ProjectedSurplus
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

<body>

<cfdump var="#APPLICATION.companyName#">

</body>
</html>

Throws an error. Must I restart the cf server each time I make a change to Application.cfc?

Reply With Quote
  #6 (permalink)  
Old 10-08-2008, 09:13 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

The only application variable I see is companyname. Are you able to access it in any pages in that application?
Reply With Quote


  #7 (permalink)  
Old 10-08-2008, 09:32 PM
ProjectedSurplus
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

NO, I cannot access that (or any APPLICATION.____ that I have similarly created) variables in my pages


Reply With Quote
  #8 (permalink)  
Old 10-08-2008, 09:51 PM
Dan Bracuk
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

It could be a file location thing. Is the template where you are attempting to access the application variable in the same directory as the application.cfc file or a sub-directory of it?
Reply With Quote
  #9 (permalink)  
Old 10-08-2008, 11:00 PM
Adam Cameron
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

> Throws an error. Must I restart the cf server each time I make a change to Application.cfc?

Changing the bit of it that only runs when *the application first starts*?
Yes.

I ran a test rig with your Application.cfc, and it works fine.

--
Adam
Reply With Quote


  #10 (permalink)  
Old 10-08-2008, 11:33 PM
ProjectedSurplus
 
Posts: n/a
Diggs:
Default Re: Application Variables vs Request Variables

is there a setting in the cf administrator that could be doing this?
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:59 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk