Application.cfc Form Validation

Hi all. I posted this question on the
site I got the
example from, but they removed my question for whatever reason so
I'll try here:
Please click the link for the code:
Click Here
I tried this example, and it works, however a couple of
things I'm trying to figure out:
1. The validation errors change their
order each time you re-submit, is there a way to control
that?
2. I tried populating the form
elements with what was posted, but the form isn't posting anything,
and I'm looking to see if anyone else has this problem
Thanks.

Hey.. Not sure what happened to my 2 points above. The
preview looked fine before I submitted it. Weird!
Anywho.....
Thanks for your reply Dan.
This (amongst other code) is what they put in there:
<cffunction name="onError" returntype="void">
<cfargument name="exception" required="true" />
<cfargument name="eventName" type="String"
required="true" />
<cfif isDefined('exception.StackTrace') AND
isDefined('exception.errors')
AND exception.StackTrace contains
'coldfusion.filter.FormValidationException'>
<cfset session.validationError = exception.errors />
<cfset session.stFormData = duplicate( form ) />
<cflocation url="#cgi.HTTP_REFERER#" addtoken="false"
/>
<cfelse>
<cfthrow object="#exception#" />
</cfif>
</cffunction>
So,why would this be a bad idea?
Oh, and if the above code makes it ok to add to
Application.cfc, then my quesitons 1 and 2 were:
1. The validation errors return in different orders every
time the form is posted, and was wondering how to control this.
2. I couldn't get the form to post any values.

Similar Messages

  • Is there a way to bypass the form Validation

    I'm getting really upset with the Coldfusion built-in form validation for any HTML formfield ending by _date , _required, _time and so on...
    My application proposes to the users to create some Properties for an object and later on to modify the values for all these properties.
    I've got a piece of code building dynamically some form fields named just like the properties (by a simple cfloop on a DB query getting the property list).
    And a registering page to records the new value in the DB.
    But it crashes onto the classical "
    Form entries are incomplete or invalid.
    I can't control what the users set as property name (one of them was Checklist_required).
    Is there any way to prevent this error by disabling this auto validation ?
    (I'd like to avoid having to rename any field dynamically created and rename any forms variables before registering them on the DB : it's just NO WAY for me to rename the properties created by the users)

    Fober1, that's not how it works.  It's pretty much the ultimate example of the disjoint between how HTML forms work and how the naive CFML Cfform / cfinput design wished they work.
    When a request is being processed by the coldfusion server, it just looks at the list of FORM (POST) variable names (whether it came from cfform or not; URL/GET params are exempt), and for those with certain suffixes (_date, _required, etc.), and it assumes their existence is intended to request validation another field without that suffix.  It doesn't actually know or care whether form submission, nor the HTML rendered in the user's browser, actually came from "cfform" or "cfinput".   The composition of the request that comes in (when a user clicks on "submit", or a hacker uses any tool imaginable) is out of the server's hands.  The cfform code is not used during form submission processing, because the receiving template (the form action="this_one.cfm") doesn't even have to be the same template that has the cfform in it. There could be multiple conflicting cfforms directing users to request the same template on a single site, with or without the validation, even without considering what a whole other person might decide to send to your server.
    The fact that it can work as intended for a typical user is irrelevant, because the purpose of validation is to deal with the atypical situation.  A malicious or merely mischievous user that wanted to circumvent the validation would simply modify a copy of the page to leave out the "validation request" fields.    For the developer to truly validate the input, additional code must be written, making the feature not only inadequate, but a complete waste of time.  There absolutely should be a way to disable it at worst; Ideally, it would be taken out of coldfusion completely.  It's not only useless, it's a security risk, wooing programmers to write code that doesn't do what they think it does.
    The error message it gives isn't so great, either, and it's a pity that it can't show more than one validation message at a time, either.  If more than one input is invalid, you could end up going through one round after another of submit + back button.
    edit: I forgot to add the other important reason that this feature should never have existed: It is a nuisance to everyone else who doesn't want to use it at all, too!  Those suffixes simply couldn't have been a worse choice, colliding with probably thousands of peoples' variable names.  Why not "*_cfval_date" "*_cfval_time" etc?

  • What is your strategy for form validation when using MVC pattern?

    This is more of a general discussion topic and will not necessarily have a correct answer. I'm using some of the Flex validator components in order to do form validation, but it seems I'm always coming back to the same issue, which is that in the world of Flex, validation needs to be put in the view components since in order to show error messages you need to set the source property of the validator to an instance of a view component. This again in my case seems to lead to me duplicating the code for setting up my Validators into several views. But, in terms of the MVC pattern, I always thought that data validation should happen in the model, since whether or not a piece of data is valid might be depending on business rules, which again should be stored in the model. Also, this way you'd only need to write the validation rules once for all fields that contain the same type of information in your application.
    So my question is, what strategies do you use when validating data and using an MVC framework? Do you create all the validators in the views and just duplicate the validator if the exact same rules are needed in some other view, or do you store the validators in the model and somehow reference them from the views, changing the source properties as needed? Or do you use some completely different strategy for validating forms and showing error messages to the user?

    Thanks for your answer, JoshBeall. Just to clarify, you would basically create a subclass of e.g. TextInput and add the validation rules to that? Then you'd use your subclass when you need a textinput with validation?
    Anyway, I ended up building sort of my own validation framework. Because the other issue I had with the standard validation was that it relies on inheritance instead of composition. Say I needed a TextInput to both check that it doesn't contain an empty string or just space characters, is between 4 and 100 characters long, and follows a certain pattern (e.g. allows only alphanumerical characters). With the Flex built in validators I would have to create a subclass or my own validator in order to meet all the requirements and if at some point I need another configuration (say just a length and pattern restriction) I would have to create another subclass which duplicates most of the rules, or I would have to build a lot of flags and conditional statements into that one subclass. With the framework I created I can just string together different rules using composition, and the filter classes themselves can be kept very simple since they only need to handle a single condition (check the string length for instance). E.g. below is the rule for my username:
    library["user_name"] = new EmptyStringFilter( new StringLengthFilter(4,255, new RegExpFilter(/^[a-z0-9\-@\._]+$/i) ) );
    <code>library</code> is a Dictionary that contains all my validation rules, and which resides in the model in a ValidationManager class. The framework calls a method <code>validate</code> on the stored filter references which goes through all the filters, the first filter to fail returns an error message and the validation fails:
    (library["user_name"] as IValidationFilter).validate("testuser");
    I only need to setup the rule once for each property I want to validate, regardless where in the app the validation needs to happen. The biggest plus of course that I can be sure the same rules are applied every time I need to validate e.g. a username.
    The second part of the framework basically relies on Chris Callendar's great ErrorTipManager class and a custom subclass of spark.components.Panel (in my case it seemed like the reasonable place to put the code needed, although perhaps extending Form would be even better). ErrorTipManager allows you to force open a error tooltip on a target component easily. The subclass I've created basically allows me to just extend the class whenever I need a form and pass in an array of inputs that I want to validate in the creationComplete handler:
    validatableInputs = [{source:productName, validateAs:"product_name"},
                         {source:unitWeight, validateAs:"unit_weight", dataField:"value"},
                   {source:unitsPerBox, validateAs:"units_per_box", dataField:"value"},
                        {source:producer, validateAs:"producer"}];
    The final step is to add a focusOut handler on the inputs that I want to validate if I want the validation to happen right away. The handler just calls a validateForm method, which in turn iterates through each of the inputs in the validatableInputs array, passing a reference of the input to a suitable validation rule in the model (a reference to the model has been injected into the view for this).
    Having written this down I could probably improve the View side of things a bit, remove the dependency on the Panel component and make the API easier (have the framework wire up more of the boilerplate like adding listeners etc). But for now the code does what it needs to.

  • 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>

  • Reusable form validation

    Hi all,
    Whenever I work with form validation, I prefer to use manual
    ColdFusion validation rather than the automated cfform or
    Javascript validation.
    I have included a sample of one of my form validation scripts
    below, and was wondering if there was a way of scripting this whole
    thing, perhaps to loop through the form collection to perform the
    same sort of validation on the fields included in the collection.
    Is there some sort of attribute I can add to the fields that
    require validation to flag them to the loop?
    Thinking about it I would need something to flag minimum and
    maximum length, regular expressions, and replace() of fields on
    some occasions. Am I overcomplicating something for the sake of
    saving some coding time?
    Thanks in advance,
    Paul
    Attached code:

    What you could do is look for things you do frequently and
    write a custom tag/udf/cfc to make the code re-useable. For
    example, many of my forms just have two text boxes looking for
    dates. I have a custom tag that makes sure both values actually are
    dates, that they are in the correct order, that they are not too
    far apart, and that they are within a specified period.

  • Web Form Validation Message Language Setting at Runtime when work in multi lingual environment

    Business Catalyst use the default culture language to display web form validation message.
    When we are in multi lingual environment and not using subdoamin to handle multilingual sites, we found that the validation message did appear in the default culture setting. To make this work, we need to add the below script in our template.
    <script type="text/javascript">
    $(document).ready(function(){               
    var head= document.getElementsByTagName('head')[0];
    var script= document.createElement('script');
    script.src= '/BcJsLang/ValidationFunctions.aspx?lang=FR';
    script.charset = 'utf-8';
    script.type= 'text/javascript';
    head.appendChild(script);
    </script>
    Assuming the template is in french. You can change the lang parameter in the script according to your language.

    After user 1 submits the page, it might not even be committed, so there is no way to have the pending data from user1 seen by user2.
    However, we do have a new feature in ADF 11g TP4 that I plan to blog more about called Auto-Refresh view objects. This feature allows a view object instance in a shared application module to refresh its data when it receives the Oracle 11g database change notification that a row that would affect the results of the query has been changed.
    The minimum requirements in 11g TP4 to experiment with this feature which I just tested are the following:
    1. Must use Database 11g
    2. Database must have its COMPATIBLE parameter set to '11.0.0.0.0' at least
    3. Set the "AutoRefresh" property of the VO to true (on the Tuning panel)
    4. Add an instance of that VO to an application module (e.g. LOVModule)
    5. Configure that LOVModule as an application-level shared AM in the project properties
    6. Define an LOV based on a view accessor that references the shared AM's VO instance
    7. DBA must have performed a 'GRANT CHANGE NOTIFICATION TO YOURUSER'
    8. Build an ADF Form for the VO that defined the LOV above and run the web page
    9. In SQLPlus, go modify a row of the table on which the shared AM VO is based and commit
    When the Database delivers the change notification, the shared AM VO instance will requery itself.
    However that notification does not arrive all the way out to the web page, so you won't see the change until the next time you repaint the list.
    Perhaps there is some way to take it even farther with the active data feature PaKo mentions, but I'm not familiar enough with that myself to say whether it would work for you hear.

  • Localization of form-validation messages in WebDynpro

    Hello all,
    We're trying to solve this issue:
    How to get localized (e.g. Slovak) messages which are result of form validation?
    Situation: there is a context atribute, it's type is a simple type and this attribute is bound to an UI input element. When the form is submitted, every such attribute it's checked against it's simple-type.
    So the question is how to get these messages - when validating automatically - for example:
      "Enter the value in the format 25.11.1987"
    in defined language? Is there a way how to configure/translate them?
    Thanks a lot!!
    Rado

    Hi Radoslav,
    You need use Message Pool for showing any data in the WEB Dynpro Applicaiton screen for intenationalization.
    Please refer to this link might help in you scenario :
    [Developing International Web Dynpro Applications|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/internationalization%20of%20web%20dynpro%20applications.pdf]
    Hope it helps
    Regards
    Arun

  • 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

  • Migrating application containing forms calling reports on ids9i

    i am trying to migrate an application with forms and reports.
    problem: menu.mmb contains "run_product(REPORTS..."
    i tried: result:=run_report_object(find_report_object('abr_as'), ' ');
    (and definied this report in the menu.fmb)
    rep-file and rdf-file are in the same dir as fmb-files
    i am working with oc4j standalone (without as)
    => and get: "rep-0503 Sie haben keinen Berichtnamen angegeben"...
    by the way: did anyone successfully used ifconvplsql90 (forms migration util) ???
    if i try this util, it replaces the "run_product"-line with:
    rp2rro.rp2rro_run_product(REPORTS, 'abr_as', SYNCHRONOUS, RUNTIME, FILESYSTEM, ' ', NULL);
    => FRM-41219 Bericht nicht gefunden. Ung|ltige Id.
    (and a lot of following errors...)

    G|nther,
    I am inlining my comments
    >i am trying to migrate an application with forms and reports.
    problem: menu.mmb contains "run_product(REPORTS..."
    i tried: result:=run_report_object(find_report_object('abr_as'), ' ');
    (and definied this report in the menu.fmb)
    So I am assuming that you have a reports object node of the the name "abr_as". Thus "abr_as" is not the name of the Reports module (rdf or rep).
    If abr_as is the name of the Reports physical file, then please create a Reports Object node and add this name as the physical file name in teh properties. use the name of the Reports object within your Run_Report_Object calls
    >rep-file and rdf-file are in the same dir as fmb-files
    i am working with oc4j standalone (without as)
    Make sure that the directory is known by the Reports Server. Use Reports_Path setting in the registry. Forms does not look for the Reports directly but call ReportsServices. make sure that the Reports Object property has a valid entry for a Reports module
    >=> and get: "rep-0503 Sie haben keinen Berichtnamen angegeben"...
    by the way: did anyone successfully used ifconvplsql90 (forms migration util) ???
    if i try this util, it replaces the "run_product"-line with:
    rp2rro.rp2rro_run_product(REPORTS, 'abr_as', SYNCHRONOUS, RUNTIME, FILESYSTEM, ' ', NULL);
    All that this utility does is to take teh Run_Product request and pass it to the plsql library shipped with the utility. The utility also create a Report Object node that is used with the library call. An here is where the possible problem is:
    Menu items don't have a Report Object node. Thus you need to make sure that the fmb file using this menu module does have the rp2rro entries. The easiest way to achieve this is to create a dummy run_product entry in the fmb file and run this through the converter. This adds all the rp2rrp dependecies to the fmb file. Finally remove the dummy run_product entry (that now shows converted) but leave the rp2rro parameters , Reports Object node and attached library.
    >=> FRM-41219 Bericht nicht gefunden. Ung|ltige Id.
    (and a lot of following errors...)
    The are some known issues with the rp2rro.pll (the call to Reports9i Services has a wrong format) that will be fixed in the first Forms9i patch that comes out soon.
    A Whitepaper about integrating Forms9i with Reports9i will be available on OTN in mid december (It's currently reviewed)
    Frank

  • Application.cfc site variables

    I switched over to using application.cfc not too long ago. One thing I have struggled with is how to set variables that I use on individual pages of my site like I used to do in application.cfm. I have some passowrds for sftp services etc that I used to set in application.cfm. I have not been able to figure out how to make them work with application.cfc so I can call them where I need to.
    I have tried setting them in onrequeststart, onapplicationstart etc. but nothing seems to work. The variables are never defined.
    Does anyone have a working example of how to set variables that can be used on your site globally?
    Is there a better way to store account passwords and variables like that that I am missing?

    For security reasons, I would try to avoid embedding the password anywhere in your ColdFusion code.  You might put it in a "config" file outside of the webroot, then use ColdFusion to read it into an appropriately scoped variable.  Assuming you don't <cfdump> or WriteDump() your variable scopes anywhere in your production code, and that you don't have "Enable Request Debugging Output" enabled on your production server, you could store the password in either the Application scope or a local page's variables scope.  If there is only one page that will do FTP communication, then loading the password into a variable on that page would be fine.  If you modularize the FTP stuff so it can be reused elsewhere in your application, then put the password in a variable in the application scope.
    Since you'll need to pass an the password to the FTP connection, you can't hash it for added security, which is the best way to handle passwords.  But you can encrypt/de-encrypt it using various functions within ColdFusion.  I'd consider at least storing it in an encrypted form in the "config" file.  While being no where near perfect security, it is better than storing the password in plain text in a file.
    -Carl V.

  • Important form validation regression

    Hi,
    Using ADF Faces/Trinidad + ADF Data Bindings + ADF Business Components.
    I was experimenting with task flows vs transaction control vs form validation and met an important regression in 11G.
    To reproduce, build a simple form with a commit button. Make sure one of the field displayed in the form is bound to an entity attribute with a simple validation (like a length validation). Run the form (edit a row) and follow these steps:
    1- Edit the field value mentioned above and make sure the value will fail the validation;
    2- Press the commit button;
    3- Server returns an error message;
    4- DON'T fix the error, but modify another field value and make sure the value will pass the validations;
    5- Press the commit button;
    6- Server does not return an error. Commit is successful. Value in error is rollbacked to the original value?!?!?!?!?!??
    Reproduced with two applications. The first one was built from scratch with 11G. The second one was built in 10.1.3.3 and migrated to 11G. For your information, in 10G it worked perfectly!
    Thanx!
    Olivier

    Please email me a 10.1.3 sample application (removing the adf-faces-impl.jar and jsf-impl.jar) to keep the size down. Thanks. ([email protected])
    Please make your file be a *.jar or *.zipp extension since our email rejects *.zip files.
    Also, it would be helpful if you include a URL to this forum posting in your email for back-reference.

  • CUP Application not a Valid Application

    I wanted to add a new Application (Non SAP) to the Request form.  So under Configuration Tab; I clicked Application Configuration and selected Created.  I filled out the Application, Sort Description, and Description field.  I left System ID and Client blank since this is an not SAP Application.  When creating a request; I can select the Application from the Others tab, but when I go to select roles It tells me "Select at least one valid application." 
    How do I add my application as a valid application?

    I have my LDAP Connection; which would be great to use; but it is not an option as an application.  How do I create a connection to Active Directory without using a LDAP connection; or how can I get my LDAP to show up as an Application? 
    Just to Clarify; when I go into Applicaiton Configuration; I can see my LDAP conneciton; but the Application field is left blank.  I assume that is why when you create a request; I do not see the LDAP as an option.  I can not select my LDAP Connection to change the Application field. 
    Any Suggestions?

  • SunOne 7 FORM Validation & Initial page

    Hi All.
    I have an application running in a Sun One 7 Server. I use LDAP for validation and I have configured a FORM validation, with two html's for login and error.
    All goes OK, when I'm trying to get the initial JSP of the application, the login form comes. But when I validate, my browser calls an image of the JSP instead of the JSP.
    It seems like the JSP tryes to load this image and then the validation starts. But when I validate, Sun One don't remember that the JSP called the image and only load the image.
    I'm blocked and I don't find nothing in the documentation. In the logs nothing appears to be bad.
    Somebody could help me, please?
    Thanks a lot.
    Daniel.

    hi
    i need to authenticate the requests of my sun application server with an ldap server.
    u told that u have configured how to connect sun app sever and ldap server....
    I need to do the same for my project......so pls help me
    ill b thankful to u..
    u can mail ur reply at [email protected]
    [email protected]
    or here

  • OIM11gR2 - How to migrate an Application Instance Form

    Hello,
    I'm trying to migrate an Application Instance Form from my Dev env to my QA env.
    My target system is SAP
    I performed the following steps in Dev:
    1. Installed and configured the SAP Connector (no problem here)
    2. Created a sandbox
    3. Created an Application Instance
    4. Created the Application Instance Form
    5. Ran a target reconciliation to confirm everything is working properly
    6. Exported the sandbox
    7. Published the sandbox
    8. Via Deployment Manager I exported all objects related to SAP (Resource object, Process Forms, Lookups etc.)
    In QA I did:
    9. Installed and configured the SAP Connector (no problem here)
    10. Via Deployment Manager I imported the objects related to SAP
    11. Imported the sandbox
    Problem:
    To my surprise, the Application Instance does not have a Form in the QA env.
    I had to create it manually by performing the following:
    12. Create a sandbox
    13. Open the Application Instance definition
    14. Click on create (to create a form)
    15. Entered the same name I used in my Dev environment
    16. Received an error message saying that the form already exists
    17. Entered a different name for the Form
    18. Saved
    19. Exported the sandbox (to import in Prd)
    20. Published the sandbox
    21. Ran a target reconciliation to confirm everything is working properly
    I tried to reproduce the problem with another (test) destination environment because I don't want to have the same problem when migrating to Prd.
    I repeated the steps 9,10,11 except that I imported the sandbox exported from QA (step 19) instead.
    The same problem: Application Instance definition has no Form attached to it in my test destination environment.
    If I try to create the form with the same name, it gives an error message saying it is already there.
    Is my procedure wrong?
    Is there an official procedure explaining how to migrate only Application Instance Form from one env to another?
    My env:
    OS: Windows 2008 R2 SP1
    OIM: 11gR2 BP7
    SAP connector: 9.1.2.2.0
    Thanks,
    Adr

    This is a bug: Bug:16027176
    Check the [Article ID 1515225.1] which proposes a workaround that might be useful in your case (it was not in mine).
    In short the workaround is:
    The following order should be observed to export :
    - IT Resource & Application instance in one xml
    - Request DataSet in another xml
    - SysAdmin Sandbox (the one defined while creating the Application Instance and the Form)
    - Identity URL Sandbox (defined while customizing the fields on the Form, in the Catalogue page)
    Adr

  • 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.

Maybe you are looking for

  • How do I update the result table ?

    I am having problem to design and update the competition results in WPC_RESULTS table. I have 3 tables 1. WPC_COMPETITION - It has details of the competition to be conducted. 2. WPC_MEMBERS - Member details. 3. WPC_RESULTS - Competition results which

  • T510 Intel My WiFi

    I activated the Intel My WiFi technology on my T510 but the system will not let me enable it. When I click on enable in the My WiFi application it never turns on. I have done everything in the KB article below. http://forum.lenovo.com/t5/T400-T500-an

  • I am lost.. downloaded firefox successfully to phone but don't know what to do next.but

    Need for Samsung tab 4

  • Photoshop Elements Organizer stops working

    I just installed Photoshop Elements 12 and when I open the Organizer, I get a message that the program has stopped working and is going to close, while the Editor is still operational.  I uninstalled Elements 10 before my new installation.  How can I

  • I am a student how can I get my serial number?

    I have just bought Adobe student but can not seem to register it online or input the required serial number when asked. Very frustrating. Please help????