Skip to main content
Inspiring
August 16, 2008
Question

Idiots guide to application.cfc

  • August 16, 2008
  • 16 replies
  • 2472 views
Hi all,
The code is my very simple application.cfm and onrequestend.cfm how do I combine them into an application.cfc? Thank you
This topic has been closed for replies.

16 replies

Inspiring
August 29, 2008
Hi bkbk so the solution is to cfinclude? thank you for your patience with this idiot!
BKBK
Community Expert
Community Expert
August 29, 2008
I need closing tags otherwise my xhtml won't validate

I understand. However, you may omit the tags in pairs, hence, <body> and </body>, <html> and </html> and so on.
Inspiring
August 29, 2008
I don't understand I need closing tags otherwise my xhtml won't validate!!
BKBK
Community Expert
Community Expert
August 27, 2008
I prefer seeing the code up front, instead of a cfinclude. Again the html tags are unnecessary.

Inspiring
August 27, 2008
Thanks BKBK that is an interesting thread. Last small question- I think I know the answer- but the code I have in the onRequestEnd method could (and should as I have html tags in it) be on an cfinclude instead? TIA

<cffunction name="onRequestEnd" hint="All pages and CFCs in the request have been processed: equivalent to the OnRequestEnd.cfm page">
<cfargument type="String" name = "targetTemplate" required=true/>
<!--- code to run when a request ends --->
<div id="footer">
<p><cfscript>
tzoneObj = createObject("java","java.util.TimeZone");
tzone = tzoneObj.getTimeZone("Europe/London");
date_format = createObject("java","java.text.DateFormat").getDateTimeInstance();
date_format.setTimeZone(tzone);
writeoutput("Time London: "&#date_format.format(now())#);
</cfscript>
<a href="login.cfm">login</a></p></div></div>
</body></html>
</cffunction>
BKBK
Community Expert
Community Expert
August 27, 2008
Hydrowizard, you might wanna have a look at another thread on Application.cfc
Inspiring
August 27, 2008
ah so yeah I asked the wrong question then!doh! -it was how do I pass the value to the argument and why would I want to anyway?! Thank you #arguments.targetpage#
Inspiring
August 27, 2008
quote:

Originally posted by: Hydrowizard
ah so yeah I asked the wrong question then!doh! -it was how do I pass the value to the argument and why would I want to anyway?! Thank you #arguments.targetpage#


Interesting question. You would want to pass the argument or the page won't work. I've only written one application.cfc file and I didn't use an onRequest function. I did use onRequestStart and onRequestEnd though.

Looking at your original question, I don't see where you need an onRequest function either.
BKBK
Community Expert
Community Expert
August 26, 2008
3.BKBK if I used the onrequest method then where and how do I set the #Arguments.targetPage# value?

<cffunction name="onRequest">
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="#Arguments.targetPage#">
</cffunction>


Something like that, actually.

August 26, 2008
Her eis another GREAT link for you to take a peak at - Ben did a good job spelling this out for us......

http://www.bennadel.com/blog/726-ColdFusion-Application-cfc-Tutorial-And-Application-cfc-Reference.htm

Hope it helps some.
Chris
BKBK
Community Expert
Community Expert
August 20, 2008
If I can't have html in the Application.cfc then do I just use a cfinclude instead and include the code on my former OnRequestEnd.cfm?

You could just remove tags like <body>, <html> etc.

I had to include my index.cfm page on the OnRequestStart
function to make it show but none of the links work. Do I have to
cfinlcude all the .cfm pages now?!! Confused!! What do I do?!!


1) Make sure Application.cfc and index.cfm are in the same directory.

2) Comment out the function onRequest. You apparently don't need it. Besides, it is presently incomplete.

If you decide to use the onRequest method, then it must explicitly call the target page, for example, by means of a cfinclude tag.

<cffunction name="onRequest">
<cfargument name="targetPage" type="String" required=true/>
<cfinclude template="#Arguments.targetPage#">
</cffunction>




Inspiring
August 21, 2008
Thanks for those replies, but not working I mean that the links although they show in the index.cfm they don't work ie they don't go anywhere. 1) Make sure Application.cfc and index.cfm are in the same directory- they are

2) Comment out the function onRequest. You apparently don't need it. Besides, it is presently incomplete- right I've got some work to do I'll get cracking and I hope to be able to work it out with all your excellent help. I also RTFM again for the onrequest function.

Thanks!!