I am stumped here. I am trying to learn how to utilize the full power of CFC's in a better practice way (working my way towards best practices). I am building an administrative application. I have put the queries into a data CFC, my business logic into its own CFC, and thus leaving the display code in its own CFM file.
This has been working well so far, but I have found my self in a dark alley and I can not see how to code myself out of it. I'm looking for some basic strategy suggestions on how to build this in a more OO/multi-tier and less procedural way. The path I have followed so far is something like this: Form.cfm This is just what it says, a file that contains a form. App.cfc This file is a middleman CFC that the form submits to using the following structure. My current thinking is that this file is doing the validation and verification of the data submitted from the form according to the business needs. <form action="app.cfc"...> <input type="hidden" name="method" value="formMethod"> ... </form> Data.cfc This is the CFC that the App.cfc utilizes to actually get the data from the form into the database. It contains the database logic and SQL statements. The trouble I am experiencing is that the logic in the app.cfc has two exits. First of all, my understanding of best practices makes me feel that this may be a bad result of itself, but I do not see a way to rearrange the pieces of my code to eliminate this. Secondly, even if I accept the two exits from the App.cfc method, I can't figure a way to actually make it work. The problem is that the formMethod() function is checking the data from the form, if the data is valid; it calls the appropriate method of the data.cfc to get the data into the database. But what do I do when the data is invalid? The program flow needs to somehow get back to the form with information about why the data is invalid, so that the user can be prompted to correct the errors. Since the form has been submitted to the App.cfc that is where the logic "pointer" is currently located. In other words, if I don't do anything to relocate and just finish processing, the URL of the browser will be such as "http://aWebSite/app.cfc". So how can I get the location and the error data back to the form.cfm file? I tried to store the error data in the session scope to persist it and then us a <cflocation...>, but that does not seem to work. When I dump the session scope in the form file, it is unaware of any of the values set in the app.cfc code. I think I have run into this problem before. It seems that if one submits forms to cfc methods for processing, this cfc has a separate world of persistent variables. I can set and output values in application or session scope in the cfc, but not from files that come after the cfc. So can somebody guide me to a better way to organize my logic so that I do not have the two exits currently required from the app.cfc formMethod() function? Or at least help me figure out how to get the data from this method back to the originating form? Thank you much. -------------- Ian Skinner Web Programmer BloodSource www.BloodSource.org Sacramento, CA "C code. C code run. Run code run. Please!" - Cynthia Dunning Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184627 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54