Multiple datasources on Application.cfc file

Is it possible to list multiple datasources on a
Application.cfc file? If not would I just have to create a sub
folder, create another Application.cfc and then that will control
the folders below it?

quote:
For instance I set my datasource in the the application.cfc
<cfset REQUEST.dataSource = "mydata">
REquest.dataSource is just a variable name, you can have as
many
variable names as you like to define datasource strings.
Hard Coded Variable Names:
<cfset REQUEST.dataSourceOne = 'aDSN'>
<cfset REQUEST.dataSourceTwo = 'bDSN'>
Array Variable:
<cfset request.dataSource = arrayNew(1)>
<cfset request.dataSource[1] = 'aDSN'>
<cfset request.dataSource[2] = 'bDSN'>
Structure Variable:
<cfset request.dataSource = StructNew()>
<cfset request.dataSource.firstDSN = 'aDSN'>
<cfset request.dataSource['secondDSN'] = 'bDSN'>
A list:
This would really suck. I can not think of any good reason to
use this
horrible method.
<cfset request.dataSource = 'aDSN,bDSN'>
You would then access these values like this.
<cfquery
datasoruce="#listGetAt(request.dataSource,2)#"...>
Define as many Datasources as you need and use them in your
code. Its
just data.
Go whole hog and build a CFC that has methods that you can
pass a
parameter into and it will return the DSN.
<cfquery
datasource="#myCFCvariable.getDSN(aValue)#"...>
OK! This one is probably overkill.

Similar Messages

  • What's wrong with my Application.cfc file

    I've decided to convert an old app from using Application.cfm to Application.cfc, mainly because I want to use onRequestStart and the like, and I can't get them to initialize in Application.cfm.
    But for some reason, this Application.cfc file causes my pages to come up blank.  I can't for the life of me figure out why, since it's copied from an app that works perfectly fine.
    <cfcomponent>
        <cfset this.name = "myapp">
        <cfset this.sessionManagement = true>
        <cfset this.sessionTimeout = CreateTimeSpan(0,2,0,0)>
        <cfset this.loginStorage="session">
        <cfset this.scriptProtect = true>
        <cfset this.setclientcookies = false>
        <cffunction name="onApplicationStart">
            <cfset application.dsource = "mydsn">
            <cfset application.appid = "123456">
            <cfset application.appname = "myappname">
        </cffunction>   
        <cffunction name="onSessionStart">
            <cfparam name="session.trackingno" default="0">
            <cfparam name="session.emailaddr" default="">
            <cfparam name="session.newitem" default="1">
            <cfparam name="session.authserver" default="">
            <cfparam name="session.id" default="">
            <cfparam name="session.rights" default="">
            <cfparam name="session.userid" default="">
            <cfparam name="session.sauth" default="">
            <cfparam name="session.creds" default="">
        </cffunction>
          <cffunction name="onRequest" output="true">   
            <cfinclude template="/planning/application.cfm">   
            <cfinclude template="/planning/tpea/2015/validate.cfm">
          </cffunction>
    </cfcomponent>
    What have I done wrong?

    What is in the two templates you are including inside your onRequest() function?  Do they actually output any content?
    You don't have the actual requested page being included.  You need to add an argument to the top of the function to receive the requested page:
    <cfargument name="TargetPage" type="string" required="true">
    Then you need to add another <cfinclude> to include that page:
    <cfinclude template="#arguments.TargetPage#" />
    You'll have to figure out if that include should come before or after your existing includes.
    -Carl V.

  • Multiples DSNs' application.cfc

    Hi All,
    Is it possible to set the multiple datasources on a Application.cfc using this.datasouce attribute?
    CF 9, from application.cfc, you  can set
    <cfset this datasouce ="myDSN1" > and no need to specify the DSN in the query.  My question is if I have multiples Datasouces, how can i set them up in application.cfc?
    <cfquery name="qDoctype">
    select * from type
    </cfquery>
    Thanks

    You can't set up multiple datasources in Application.cfc to be used **implicitly** in your queries.  The "this.datasource" can only be set to one datasource name.  However, nothing is stopping you from storing a structure of datasource names in the application scope:
    <cfset application.myDSNs = StructNew()>
    <cfset application.myDSNs.DSN1 = "myDSN1">
    <cfset application.myDSNs.DSN2 = "myDSN2">
    Then in your query, you would do:
    <cfquery name="qDoctype" datasource="#application.myDSNs.DSN1#">
    HTH,
    -Carl V.

  • Application.cfc saving old datasource?

    I had a site on one server that I am moving to a new server.   I copied the files and database and created a new DSN.  I ran a simple query on a test page prior to moving the site, it was a one page site at that time.  I was able to connect to the database.
    Now I have a relatively simple application file.  I changed the name of the data souce in the file, but prior to that I made the mistake of opening a page on the site.  The old data souce is A, the new data source is B.  The application.cfc clearly (now) says B, but I get an error on every page saying it can't find A.  I did a search of the entire site and nowhere in any file does it list data source A.
    Here is the application file.
    <cfcomponent output="false">
      <!--- Name the application. --->
      <cfset this.name="SomeName">
      <!--- Turn on session management. --->
      <cfset this.sessionManagement=true>
      <cffunction name="onApplicationStart" output="false" returnType="void">
        <!--- Any variables set here can be used by all pages --->
        <cfset APPLICATION.DSN = "B">
              <!--- Define the mail server --->
              <cfset APPLICATION.MailServer = "MailServer">
              <cfset APPLICATION.AdminMail = "EMailAddress">
        <cfset APPLICATION.AdminMailPass = "PassWord">
      </cffunction>
    </cfcomponent>
    Any thought on what I've done wrong?
    Thank you!

    ctreeves wrote:
    ... The old data souce is A, the new data source is B.  The application.cfc clearly (now) says B, but I get an error on every page saying it can't find A.  I did a search of the entire site and nowhere in any file does it list data source A.
    The answer to the puzzle is as follows. The original application was still running in memory, with datasource A, even after you had modified the Application.cfc file. That is because the original application has not yet timed out, which means onApplicationEnd() has not yet been triggered.
    The easiest way I know to reset an application is to change the application name. To do so in your case, change the line
    <cfset this.name="SomeName">
    to, for example,
    <cfset this.name="SomeName2">.
    Oh, and I hope you have saved the application file as Application.cfc, with capital A.

  • Tracking users in the Application.cfc, please help

    Hello;
    I wrote a small tracking system for my web site. I am trying
    to upfrade it to work in CF 8. Here is what I am doing.
    I had this code on the index.cfm page of my site. I am
    attempting to move it to the Application.cfc file. When I do, it
    registers in the DB every time the user hits a page or clicks a
    link. I don't want it to do that. I do want it to tell me when they
    hit the site, and if I can what page they came in on.
    Here is my code:
    <cfquery name="tracking" datasource="my-DB"
    dbtype="ODBC">
    INSERT INTO tracking (REMOTE_ADDR, HTTP_USER_AGENT,
    TRACK_DATE, PageID)
    VALUES('#REMOTE_ADDR#', '#HTTP_USER_AGENT#',
    #CreateOdbcDateTime(now())#)
    </cfquery>
    My pageID is where I want the information on what page the
    user came in on to go.
    I placed teh query inside a session function code, but it
    doesn't work at all right now, I need to limit the hits counted by
    the Application.cfm, if I place it inside the area of the app that
    is for global variables, it adds info to the DB everytime they
    click a link and I don't want that. As for the entry page of the
    user, I am trying to make it so if someone enters the site lets say
    on the about.cfm page, that is added to the db and so on. Is this
    possible? If so how would I do that?
    Here is my application.cfc code so far:
    <cfcomponent output="false">
    <cfset THIS.name = "my-web">
    <cfset this.sessionManagement="yes">
    <cfset this.clientManagement=true>
    <cffunction name="onApplicationStart" returntype="boolean"
    output="false">
    <cfset APPLICATION.appStarted = now()>
    <cfreturn true>
    </cffunction>
    <cffunction name="onApplicationEnd" returntype="void"
    output="false">
    <cfargument name="appScope" required="True">
    <cflog file="#THIS.name#" text="App ended after
    #dateDiff('n' , ARGUMENTS.appscope.appStarted,now())# minutes.">
    </cffunction>
    <cffunction name="onSessionStart" returntype="query"
    output="true">
    <cfquery name="tracking" datasource="creative"
    dbtype="ODBC">
    INSERT INTO tracking (REMOTE_ADDR, HTTP_USER_AGENT,
    TRACK_DATE)
    VALUES('#REMOTE_ADDR#', '#HTTP_USER_AGENT#',
    #CreateOdbcDateTime(now())#)
    </cfquery>
    </cffunction>
    <cffunction name="onRequestStart" returntype="boolean"
    output="true">
    <cfset request.datasource = "my-db">
    <cfset sitePath = "
    http://www.myweb">
    <!--- this is where I was putting the tracking code and it
    added to the DB everytime someone clicked a link. not what I want
    --->
    <!--- Start True Url Variables --->
    <cfloop
    list="#removeChars(cgi.path_info,1,len(cgi.script_name))#"
    delimiters="/" index="variableSet">
    <cfscript>
    variableName = "url." & listGetAt(variableSet,1,'.');
    expression = listGetAt(variableSet,2,'.');
    </cfscript>
    <cfparam name="#variableName#" default="#expression#">
    </cfloop>
    <!--- Finish True Url Variables --->
    <cfreturn true>
    </cffunction>
    </cfcomponent>
    Thank you.
    Phoenix

    I did a dump and got it to error out, so it is recognizing
    the session, but it doesn't add any info to the DB. I also had to
    change it, I had it like this:
    <cffunction name="onSessionStart" returntype="query"
    output="true">
    <cfquery name="tracking" datasource="my-db"
    dbtype="ODBC">
    INSERT INTO tracking (REMOTE_ADDR, HTTP_USER_AGENT,
    TRACK_DATE)
    VALUES('#REMOTE_ADDR#', '#HTTP_USER_AGENT#',
    #CreateOdbcDateTime(now())#)
    </cfquery>
    </cffunction>
    Changed it to this:
    <cffunction name="onSessionStart" returntype="any"
    output="true">
    <cfquery name="tracking" datasource="creative"
    dbtype="ODBC">
    INSERT INTO tracking (REMOTE_ADDR, HTTP_USER_AGENT,
    TRACK_DATE)
    VALUES('#REMOTE_ADDR#', '#HTTP_USER_AGENT#',
    #CreateOdbcDateTime(now())#)
    </cfquery>
    </cffunction>
    it was erroring on the query attribute before in the session
    function. Even that change didn't get it to work properly.

  • Work around for Application.cfc

    I have an Application.cfc file that outputs a header and footer page for every request.  That works wonderful but if I try to open a page that is doing a <cfgrid> using a CFC file than I get an error of "Error invoking CFC /GATS/CFC/purchaseOrder.cfc : Internal Server Error [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]" when opening the page.
    Commenting out the header/footer include in the Application.cfc file lets the <cfgrid> populate with the CFC file.  Is there a fix or work around for this?
    Application.cfc file
    <cfcomponent output="false">
    <cffunction name="onRequestStart" returnType="boolean" output="true">
          <cfargument name="thePage" type="string" required="yes">
         <cfset PageName = GetFileFromPath(thePage)>
        <cfif not IsDefined("session.user.isAuthenticated") or
              session.user.isAuthenticated equal session.no>
          <cfif FindNoCase('index.cfm', PageName) is not 0>
            <cfelse>
              <cfset session.messages[1] = "Authentication required.">
              <cflocation url="#application.WebAddress#" addtoken="no">
          </cfif>
        </cfif>
        <cfif FindNoCase('index.cfm', PageName) is not 0>
          <cfset request.PageNavigation = "">
          <cfset request.Screen = "Login">
        </cfif>
        <cfif FindNoCase('mainMenu.cfm', PageName) is not 0>
          <cfset request.PageNavigation = "Home">
          <cfset request.Screen = "">
        </cfif>
        <cfif FindNoCase('purchaseOrder.cfm', PageName) is not 0>
          <cfset request.PageNavigation = '<a href="mainMenu.cfm">Home</a> &##8226; New Purchase Order'>
          <cfset request.Screen = "">
        </cfif>
        <cfif FindNoCase('logout.cfm', PageName) is not 0>
          <cfelse>
            <cfinclude template="includes/header.cfm">
        </cfif>
        <cfreturn true>
      </cffunction>
    <cffunction name="onRequestEnd" returnType="void" output="true">
          <cfargument name="thePage" type="string" required="yes">
        <cfset PageName = GetFileFromPath(thePage)>
        <cfif FindNoCase('logout.cfm', PageName) is not 0>
          <cfelse>
            <cfinclude template="includes/footer.cfm">
        </cfif>
      </cffunction>
    </cfcomponent>
    purchaseOrder.cfm
    <cfgrid name="AccountGrid" format="html" bind="cfc:GATS.CFC.purchaseOrder.GetQuantities({cfgridpage},{cfgridpagesize}, {cfgridsortcolumn}, {cfgridsortdirection})">
      <cfgridcolumn name="ID" header="ID" display="yes">
      <cfgridcolumn name="vendor_name" header="Name" display="yes">
    </cfgrid>
    I found this on the web:
    That error is due to our application.cfm having a single HTML comment at the
    start of the file. Apparently if your Application.cfm or Application.cfc file
    outputs ANYTHING, binds to CFCs with AJAX (via HTML CFGRID or CFAJAXPROXY, for
    example) do not work. The CFC will be called, but the data from it will never
    "flow" into the CFGRID. Removing the comment from the Application.cfm file took
    care of our CFGRID issue.
    This there a way to have an Application.cfc file that displays a header and footer for every page and have and
    have a page have a <cfgrid> in it?

    BKBK,
    I created the examples you posted and commenting out the header/footer lines in my Application.cfc displayed the cfgrid results (updating the query to a table I had).  Running the same example code with the header/footer included in the Application.cfc would not show the cfgrid results.
    I attached the Application.cfc file for review.
    Couldn't attach the file.
    Application.cfc
    <cfcomponent output="yes">
      <cfset this.name = "GATS">
      <cfset this.clientmanagement = "true">
      <cfset this.applicationtimeout = CreateTimeSpan("0","0","20","0")>
      <cfset this.sessionmanagement = "true">
      <cfset this.sessiontimeout = CreateTimeSpan("0","0","20","0")>
      <cfset this.scriptProtect = "true">
      <cfparam name="session.yes" default="Yes">
      <cfparam name="session.no" default="No">
      <cffunction name="onApplicationStart" returnType="boolean" output="no">
        <cfset application.Directory = "/GATS/">
        <cfset application.Datasource = "IA-webapplications">
        <cfset application.DatasourceGATS = "SBS-GATS">
        <cfreturn true>
      </cffunction>
      <cffunction name="onApplicationEnd" returntype="void" output="no">
        <cfargument name="ApplicationScope" required="yes" />
      </cffunction>
      <cffunction name="onSessionStart" returntype="void" output="no">
        <cflock scope="session" timeout="5" type="exclusive">
          <cfset session.no = "No">
          <cfset session.yes = "Yes">
          <cfset session.new = "New">
          <cfset session.user = StructNew()>
          <cfset session.user.isAuthenticated = session.no>
          <cfset session.user.emplid = ""> 
          <cfset session.user.userSSOId = "">
          <cfset session.user.firstName = "">
          <cfset session.user.lastName = "">
          <cfset session.user.name = "">
          <cfset session.messages = ArrayNew(1)>
          <cfset session.savedInputValues = ArrayNew(1)>
          <cfset session.filesTransferred = "">
        </cflock>
      </cffunction>
      <cffunction name="onSessionEnd" returntype="void" output="no">
        <cfargument name="SessionScope" required="yes">
        <cflock scope="session" timeout="5" type="exclusive">
          <cfset Arguments.SessionScope.user.isAuthenticated = session.no>
          <cfset Arguments.SessionScope.users.emplid = ""> 
          <cfset Arguments.SessionScope.user.userSSOId = "">
          <cfset Arguments.SessionScope.user.firstName = "">
          <cfset Arguments.SessionScope.user.lastName = "">
          <cfset Arguments.SessionScope.user.name = "">
        </cflock>
      </cffunction>
      <cffunction name="onRequestStart" returntype="void" output="yes">
        <cfargument type="String" name="TargetPage" required="yes">
        <cfset PageName = GetFileFromPath(TargetPage)>
        <cfif not IsDefined("session.user.isAuthenticated") or
              session.user.isAuthenticated equal session.no>
          <cfif FindNoCase('index.cfm', PageName) is not 0>
            <cfelse>
              <cfset session.messages[1] = "Authentication required.">
              <cflocation url="#application.WebAddress#" addtoken="no">
          </cfif>
        </cfif>
        <cfif FindNoCase('index.cfm', PageName) is not 0>
          <cfset request.PageNavigation = "">
          <cfset request.Screen = "Login">
        </cfif>
        <cfif FindNoCase('mainMenu.cfm', PageName) is not 0>
          <cfset request.PageNavigation = "Home">
          <cfset request.Screen = "">
        </cfif>
        <cfif FindNoCase('purchaseOrder.cfm', PageName) is not 0>
          <cfset request.PageNavigation = '<a href="mainMenu.cfm">Home</a> &##8226; New Purchase Order'>
          <cfset request.Screen = "">
        </cfif>
        <cfif FindNoCase('logout.cfm', PageName) is not 0>
          <cfelse>
            <cfinclude template="includes/header.cfm">
        </cfif>
      </cffunction>
      <cffunction name="onRequestEnd" returntype="void" output="yes">
        <cfargument type="String" name="TargetPage" required="yes">
        <cfset PageName = GetFileFromPath(TargetPage)>
        <cfif FindNoCase('logout.cfm', PageName) is not 0>
          <cfelse>
            <cfinclude template="includes/footer.cfm">
        </cfif>
        <cfif FindNoCase('sessionTerminated.cfm', PageName) is not 0>
          <cfinvoke method="onSessionEnd">
            <cfinvokeargument name="SessionScope" value="#session#">
          </cfinvoke>
        </cfif>
      </cffunction>
      <cffunction name="onError" returnType="void" output="no">
        <cfargument name="exception" required="true">
        <cfargument name="eventName" type="string" required="true">
        <cfthrow object="#arguments.exception#">       
      </cffunction>
    </cfcomponent>

  • Need help with application.cfc

    Here is what I am trying to do. I have a login page, and when
    a user logs in it verifies their credentials. If everything is good
    it sets a session variable called #session.username#. What I want
    to happen is at that point update a database field to set the user
    logged on status to 1. Everything to that point is fine. I am
    getting stuck at updating the databse when the users session ends.
    Before the session ends I would like to update the db field for the
    user and set the logged on status to 0.
    I haven't used application.cfc before. I have been messing
    around but nothing is working. Here is a copy of my application.cfc
    file. If anyone has any idea on how to run a query onsessionend and
    update a db I would appreciate it.
    <cfcomponent output="false">
    <cfset this.name = "test">
    <cfset this.applicationTimeout =
    createTimeSpan(0,2,0,0)>
    <cfset this.clientManagement = true>
    <cfset this.clientStorage = "registry">
    <cfset this.loginStorage = "session">
    <cfset this.sessionManagement = true>
    <cfset this.sessionTimeout = createTimeSpan(0,0,0,30)>
    <cfset this.setClientCookies = true>
    <cfset this.setDomainCookies = false>
    <cfset this.scriptProtect = false>
    <cffunction name="onApplicationStart" returnType="boolean"
    output="false">
    <cfset application.dsn = "dsn">
    </cffunction>
    <cffunction name="onSessionStart" returnType="void"
    output="false">
    <cfargument name="sessionScope" type="struct"
    required="true">
    <cfargument name="appScope" type="struct"
    required="false">
    </cffunction>
    <cffunction name="onSessionEnd" returnType="void"
    output="false">
    <cfargument name="sessionScope" type="struct"
    required="true">
    <cfargument name="appScope" type="struct"
    required="false">
    <!--- Update Logged On Status --->
    <cfquery datasource="dsn">
    UPDATE LoginNew
    SET loggedin = '0'
    WHERE username = '#session.loginname#'
    </cfquery>
    </cffunction>
    </cfcomponent>

    siriiven wrote:
    >
    > Any ideas?
    >
    Take a peak at the documentation. It describes all the ins
    and outs...
    you have to do the same thing with application variables as
    session
    variables. The hint being that you are also defining an
    appScope
    argument as well as the sessionScope argument, there is a
    reason for this.
    <quote
    src="
    http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?cont ext=ColdFusion_Documentation&file=00000701.htm">
    Usage
    Use this method for any clean-up activities when the session
    ends. A
    session ends when the session is inactive for the session
    time-out
    period or, if using J2EE sessions, the user closes the
    browser. You can,
    for example, save session-related data, such as shopping cart
    contents
    or whether the user has not completed an order, in a
    database, or do any
    other required processing based on the user’s status.
    You might also
    want to log the end of the session, or other session related
    information, to a file for diagnostic use.
    If you call this method explicitly, ColdFusion does not end
    the session;
    it does execute the method code, but does not lock the
    Session.
    You cannot use this method to display data on a user page,
    because it is
    not associated with a request.
    You can access shared scope variables as follows:
    You must use the SessionScope parameter to access the Session
    scope. You
    cannot reference the Session scope directly; for example, use
    Arguments.SessionScope.myVariable, not Session.myVariable.
    You must use the ApplicationScope parameter to access the
    Application
    scope. You cannot reference the Application scope directly;
    for example,
    use Arguments.ApplicationScope.myVariable, not
    Application.myVariable.
    Use a named lock when you reference variables in the
    Application scope,
    as shown in the example.
    You can access the Server scope directly; for example,
    Server.myVariable.
    You cannot access the Request scope.
    Sessions do not end, and the onSessionEnd method is not
    called when an
    application ends. The onSessionEnd does not execute if there
    is no
    active application, however.
    </quote>

  • SetEncoding() and application.cfc

    Is this a bug, or I just didn't understand the way it is
    supposed to work?
    I just finished determining that if one puts a <cfset
    setEncoding("form","encodingType")> in the
    psudo-consructor (after the
    <cfcomponent...> but before any <cffunction...)
    tags) of Application.cfc
    one will always receive empty form structures on an action
    page.
    When I tried moving said setEncoding() line to the
    onRequestStart()
    function. All was well? Is there a reason for this I do not
    understand
    with my very limited knowledge of page encoding?

    Application.cfc is event-driven, all its methods being
    events. I think
    you should expect to be in uncharted territory if you use any
    method
    different from the given list
    First, you can augment the functions of Applicaiton.cfc if
    you so
    desire, it is just that these functions will never be called
    by any
    event. But there is nothing wrong with them being called by
    functions
    called as a result of one of the defined events.
    Secondly, I was not doing this.
    Relevant parts of my Application.cfc file:
    <cfcomponent output="no">
    <cfprocessingdirective pageencoding="windows-1252" />
    <cfset variables.coding = "windows-1252">
    <!--- placing these setEncoding() functions here, in the
    psudo
    constructor, failed. This cause the form structure to always
    be empty. --->
    <cfset setEncoding("form",variables.coding)>
    <cfset setEncoding("url",variables.coding)>
    <cffunction name="onRequestStart" output="false">
    <cfargument name="requestname" required="yes">
    <!--- placing these setEncoding() functions here, in the
    onRequestStart, works fine. --->
    <cfset setEncoding("form",variables.coding)>
    <cfset setEncoding("url",variables.coding)>
    </cffunction>
    </cfcomponent>

  • Cfobject / cfinvoke problem in my application.cfc

    Hello;
    I am trying to use cfobject in my onsessionstart function in my application.cfc file. The cfobject is another application.cfc file I have in a sub directory in the web site, it runs the shopping cart. I am not firing this off properly and I was hoping someone could help me fix my code so it will operate properly.This is my invoke statement:
    <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
    <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">
    This is my whole argument statement for on session start:
    <cffunction name="onSessionStart" returntype="any" output="true">
    <cfset SESSION.created = now()> <!--- This sets off another session in the site --->
    <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
    <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">
    </cffunction>
    this is my error:
    Context validation error for tag cffunction.
    The end tag </cffunction> encountered on line 80 at column 11 requires a matching start tag.
    The error occurred in C:\website\Application.cfc: line 28
    26 : <cffunction name="onSessionStart" returntype="any" output="true">
    27 : <cfset SESSION.created = now()>
    28 : <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
    29 : <cfinvoke component="#SESSION.myShoppingCart#" method="getShoppingCart">
    Can anyone help me? What do I need to do to set off my shopping cart functions on the cfc I am trying to invoke?
    Thank You
    CFmonger

    this is what I am supposed to put in the on sessionstart function:
    <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">
    But this throws the same error. I am reading this off of instructions from a book. Obviously the book is wrong. Is there a way to make that cfobject statement work? I don't want a return variable. I want the ShoppingCart.cfc that resides in the sub directory /donation/ShoppingCart.cfc to go into client memory, I don't need a return value, I need the shoppong cart application portion fired when they hit the web site, creating a "shopping cart" in session / client variables.
    How would I do that using this tag? Thanks.
    CFmonger

  • Lost on application.cfc

    Hi all,
    I've used application.cfm for ages on our site (now in sustainment) and we have been moved to a new server using CF9. Our server dudes have "per application" settings in place where I can map my custom tag directory (works fine) but when I use application.cfc, I begin crashing on all my pages that use relative pathing.
    For example, the first thing the application does is query an Oracle table to get security settings. This is located off the root in a folder (oddly enough) called Security. That folder has a subdirectory called queries. I bomb with an error saying that "<cfinclude template="queries/user_role_select.cfm">" is invalid and it cannot find the noted cfm file and that I have to set up mappings in my application.cfc file.
    Does this mean that I have to provide mappings for every directory and subdirectory under my root folder? Surely not! If so, how can this be done and how would I use that mapping in my cfincludes? I'm really getting started with the cfc files late in the game so any guidance and direction is GREATLY appreciated.
    Thanks in advance!

    For example, the first thing the application does is query an Oracle table to get security settings. This is located off the root in a folder (oddly enough) called Security. That folder has a subdirectory called queries. I bomb with an error saying that "<cfinclude template="queries/user_role_select.cfm">" is invalid and it cannot find the noted cfm file and that I have to set up mappings in my application.cfc file.
    What is the EXACT error message?  Don't paraphrase it, copy and paste it from the screen.
    Also: what is the full file system path to the file with the <cfinclude> in it, and the file system path to queries/user_role_select.cfm?
    What mappings have you set in CFAdmin and in your Application.cfc pseudo constructor?  Ditto custom tag paths (although the latter ought not be relevant here)?
    Adam

  • Why does application.cfm file not get processed first?

    I am using ColdFusion 11 on Windows2008 R2. From what I understand, if there is an application.cfm page in the root folder, that any .cfm page below the root will process this page first and then process the regular .cfm page. I noticed that it processes my regular page FIRST and then calls the application.cfm page.
    In my case I have a web page that updates a database, but in my application.cfm page, I check a session variable to see if the user is logged in. If they are not logged in, then I redirect them to a log in page, let them log in, set the session variable and then redirect them back to process the page. But I noticed, that when I run the page, the database gets updated and THEN the user gets redirected to log in, then the database gets updated again.
    Am I not using the application.cfm page correctly? I thought it was supposed to be used to check log ins and things like that. How do I ensure that it runs first?
    Btw, it is the only application.cfm page in the entire web site and I do not have any application.cfc files.
    Thanks.

    It would make things easier to see the code. In any case, from what you say, my guess is that there is no authentication check at the point where the database gets updated. So the update occurs at the start, and again when you later redirect the user to the page.
    On Coldfusion 11, you should actually switch to Application.cfc. There are at least 2 reasons.
    Firstly, recent Coldfusion versions implicitly assume you use Application.cfc by default. Secondly, Application.cfm is outdated and has much less functionality than Application.cfc. For example, Application.cfc allows you much more fine-grained control over your code at the level of request, session and application.

  • CFGrid and Application.cfc - bug??

    I don't understand what is happening here.
    If I open the cfgrid.cfm page without the Application.cfc
    file it works fine.
    With the application.cfc file the grid does not populate.
    If I comment out the cfajaximport, onrequeststart, onrequest
    and onrequestend it works fine.

    the best i could find was comment #8 by Scott Jibben here:
    http://www.forta.com/blog/index.cfm/2007/6/4/ColdFusion-Ajax-Tutorial-4-Partial-Page-Updat es
    i was apparently remembering things wrong and it is
    onRequestEnd method
    that seems to be the culprit... though i suppose depending on
    what you
    have in onRequest method may make it a collaborator too... i
    know for
    sure onRequest interferes with flash remoting and invoking
    cfc's as
    webservice...
    but why do you have <cfajaximport ...> tag in your
    Application.cfc???
    iirc, that is not a good practice - you should use it on your
    .cfm page
    in general, and in your particular case i don't think you
    need it at all.
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Application.cfc, OnRequestStart, CFInclude

    O.K. I'll admit I am feeling a little stupid here but I just
    don't understand this. All I wanted to do was include my script
    library file using the OnRequestStart function withn
    application.cfm. There isn't anything special inthe _ScriptLib.cfm
    template. My Application.cfc file looks like this... (Only the
    pertinent portions are included)
    <CFFUNCTION NAME="onRequestStart" OUTPUT="Yes"
    RETURNTYPE="any">
    <CFINCLUDE TEMPLATE="_ScriptLib.cfm">
    ... (other CFSETS and junk like that)
    </CFFUNCTION >
    <CFFUNCTION NAME="onRequest">
    <CFARGUEMENT NAME="targetTemplate" type="String"
    required="true" />
    <CFINCLUDE TEMPLATE="#arguments.targetTemplate#">
    </CFFUNCTION>
    My question is why do I need to add the CFArguement tag in
    the OnRequest function to include my scripts??? Why doesn't the
    CFInclude tag in OnReq

    My question is why do I need to add the CFArgument tag in the
    OnRequest function to include my scripts???
    You don't need to add the cfargument tag to onRequest to
    enable you to use cfinclude in OnRequestStart. In this case, the
    only musts are:
    if you implement the OnRequest method, then it must load the
    target-page through a cfargument tag and it must explicitly call
    the page through a cfinclude tag.
    That makes the Variables scope of the requested page (and its
    included pages!) available in OnRequestStart. If a variable is
    called x in the requested page, you may just call it x in
    OnRequestStart. If you hadn't included the cfargument and cfinclude
    tags in OnRequest, or if you didn't iimplement the OnRequest method
    at all, the only page variables you would have access to in
    OnRequestStart are those in Request scope.

  • How to handle multiple datasources in a web application?

    I have a J2EE Web application with Servlets and Java ServerPages. Beside this I have a in-house developed API for certain services built using Hibernate and Spring with POJO's and some EJB.
    There are 8 databases which will be used by the web application. I have heard that multiple datasources with Spring is hard to design around. Considering that I have no choice not to use Spring or Hibernate as the API's are using it.
    Anyone have a good design spesification for how to handle multiple datasources. The datasource(database) will be chosen by the user in the web application.

    Let me get this straight. You have a web application that uses spring framework and hibernate to access the database. You want the user to be able to select the database that he wants to access using spring and hibernate.
    Hopefully you are using the Spring Framework Hibernate DAO. I know you can have more that one spring application context. You can then trying to load a seperate spring application context for each database. Each application context would have it's own configuration files with the connection parameters for each datasource. You could still use JNDi entries in the web.xml for each datasource.
    Then you would need a service locater so that when a user selected a datasource he would get the application context for that datasource which he would use for the rest of his session.
    I think it is doable. It means a long load time. And you'll need to keep the application contexts as small as possible to conserve resources.

  • Application.cfc & locking down media files

    Hi,
    I've used a login framework for the Application.cfc (from
    Forta's CF8 book chapter 23). It successfully locks down .cfm
    files, but media/image files such as .jpg are still unsecure.
    What am I missing to make sure that even no matter what's in
    the folder, whether it be .jpg, .gif, .mov, .swf, etc... will only
    be accessible if the site visitor has the proper login credentials?
    I could probably "lock" the media files away in a database
    structure, but that's not very efficient. I'm sure CF8 has an easy
    way to handle this that I just don't know about.
    Thank you for your help!

    Azadi wrote:
    > the only secure way to not allow access to a web content
    is to not put
    > it on the web. cf never processes those 'media' files
    you mention - it
    > is your web server that handles requests for them.
    >
    > so either:
    > a) move those files into non-web-accessible part of your
    server and
    > serve them with cf via file system interaction
    tags/functions and
    > cfcontent/cfherader combinations
    > b) configure cf to process those files instead of your
    web server
    >
    > mind you, both options above may add significant
    processing overhead to
    > your application, so balance the need to secure access
    to those files
    > and your app performance wisely...
    >
    As well as these CF solutions mentioned by Azadi, you can
    look into the
    security options of your web server and try to apply them.
    These work
    differently then the ColdFusion based solution, but they get
    to the same
    end.

Maybe you are looking for

  • How do I fix super slow internet - all browsers are affected

    There is some problem with internet connectivity with my MacBook Pro, but I cannot figure out how to resolve it.  Speedtest.net is measuring my internet speed at download speeds of 0.88MBps and upload of .84Mbps.  Other devices utilizing the same rou

  • I am on a macbook pro version 10.5.8 want to upgrade to 10.6  how do I do this on line Wally

    I want to upgrade to 10.6 from 10.5.8, please advise how to upgrade on line or do I hae to purchase new software?

  • Web I line chart formatting

    hi all, I am trying all my best for webI line chart formatting but I don't see much options, quick question is there any button or tool box for formatting  WebI line chart except properties tab??? and my requirement is, usually when i turn  table to

  • Spry dataset and Calendar widget not working

    I have created a Spry data set table on a separate HTML I have used the wizard to put that data set on my page I have attempted to bind the date section of my data set with the YUI Calendar but am failing miserably. Can anyone help me fix this proble

  • Nested Tables and Constraints??

    Hi all I have created objects like this create or replace type type_one as object (col_a number(3), col_b number(2), col_c varchar2(3 char)); create or replace type type_one_tb as table of type_one; create or replace type type_two as object (col_aa n