ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 16th, 2005, 01:23 PM
jdh0f0 jdh0f0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 80 jdh0f0 User rank is Private First Class (20 - 50 Reputation Level)jdh0f0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 54 sec
Reputation Power: 4
Angry Application variables not found :mad:

I'm using MX7 and following Forta's latest book pretty closely (pages 622-629). Below is my application file. When I run a page that attempts to call any of the application variables, I get an error message saying that the variable is undefined. What have I done wrong?

Thanks,
Jason

Code:
<CFCOMPONENT OUTPUT="false">

<CFPARAM NAME="Title" Default="">
	
  <!--- Name the application. --->
  <CFSET this.name="HumanSexuality">
  <!--- Turn on session management. --->
  <CFSET this.sessionManagement=true>

<CFFUNCTION NAME="onApplicationStart" OUTPUT="false" RETURNTYPE="void">
    <!--- Any variables set here can be used by all our pages --->
    <CFSET APPLICATION.dataSource = "courses">
    <CFSET APPLICATION.DSN = "courses">
    <CFSET APPLICATION.siteURL = "http://209.200.109.186/">
    <CFSET APPLICATION.CurrentGradeTable = "S05_253_Grades">
    <CFSET APPLICATION.companyName = "FAM 253: Human Sexuality">
</CFFUNCTION>

<CFFUNCTION NAME="onRequestStart" OUTPUT="false" RETURNTYPE="void">
	<CFINCLUDE TEMPLATE="header.cfm">
	<!--- <CFINCLUDE template="course_counter.cfm"> --->
	</CFFUNCTION>

    <!--- If user is not logged in, force them to now ---> 
    <CFIF not isDefined("SESSION.auth.isLoggedIn")>
      <!--- If the user is now submitting "Login" form, --->
      <!--- Include "Login Check" code to validate user --->
      <CFIF isDefined("UserLogin.SSN")> 
        <CFINCLUDE TEMPLATE="loginCheck.cfm">
      </CFIF>
      <CFINCLUDE TEMPLATE="loginForm.cfm">
      <CFABORT>
    </CFIF> 
	<!--- After the page loads. --->
	<CFFUNCTION NAME="onRequestEnd" RETURNTYPE="void" OUTPUT="true">
		<CFINCLUDE TEMPLATE="footer.cfm">
	</CFFUNCTION>
</CFCOMPONENT>

Reply With Quote
  #2  
Old May 16th, 2005, 01:38 PM
Bastion Bastion is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 181 Bastion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 25 m 11 sec
Reputation Power: 5
How are you calling the application variable on the .cfm page? Are you calling with Application.myvariable or just myvariable?

Reply With Quote
  #3  
Old May 16th, 2005, 02:06 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
I would start by creating a simple 1 page application with an Application.cfc file, and have nothing in there except one application variable assignment. The key is to get rid of everything that is not related to the problem and then do your troubleshooting.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #4  
Old May 16th, 2005, 03:12 PM
jdh0f0 jdh0f0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 80 jdh0f0 User rank is Private First Class (20 - 50 Reputation Level)jdh0f0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 54 sec
Reputation Power: 4
I broke it down about as simply as possible, but I still get the same error. Specifically, I get the application.datasource not defined error when I run Test.cfm and have nothing but the application variable in the application file. (When I replace the datasource with "courses" in the query it works fine.)

Thanks,
Jason

Code:
<!--- Test.cfm --->
<CFQUERY NAME="test" DATASOURCE="#APPLICATION.datasource#">
SELECT *
FROM S05_253_Grades
</CFQUERY>
<CFOUTPUT QUERY="test">
#FIRSTNAME#, #LASTNAME#<BR>
</CFOUTPUT>


Code:
<!--- Application.cfc --->
<CFCOMPONENT OUTPUT="false">
<CFFUNCTION NAME="onApplicationStart" OUTPUT="false" RETURNTYPE="void">
    <CFSET APPLICATION.dataSource = "courses">
</CFFUNCTION>
</CFCOMPONENT>

Reply With Quote
  #5  
Old May 16th, 2005, 03:48 PM
jdh0f0 jdh0f0 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 80 jdh0f0 User rank is Private First Class (20 - 50 Reputation Level)jdh0f0 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 20 m 54 sec
Reputation Power: 4
I'm not sure yet what I did to get this working, but it seems to be working properly now.

Thanks,
Jason

Reply With Quote
  #6  
Old May 16th, 2005, 04:00 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,692 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 16 h 43 m 41 sec
Reputation Power: 53
I would almost guarantee that when you added the application variables to the onApplicationStart() method, the application had *already been started*. In other words, since onApplicationStart() only runs the very first time an applicaiton is initialized, you'd either have to restart the CFMX service or explicitly add code that you can run to recall onApplicationStart() in order for your applicaiton variables to be created.

So you could run a URL like "index.cfm?refresh=true", and then in your onRequestStart() method you could have:

<cfif structKeyExists( url, 'refresh' )>
<cfset onApplicationStart() />
</cfif>

which would force a refresh of your application variables because the onApplicationStart() method would be re-run.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Application variables not found :mad:


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT