Dynamic XML Settings Download

Word Count: 169
A couple people have emailed me and asked me to post a complete code example. If you click on the download link below you will get a settings.zip file that contains 3 files
  • Application.cfc
  • Index.cfm
  • org.danvega.Settings.cfc
The Application component will show you a quick of example of how to instantiate the object and place it into the application scope. I would normally do this via ColdSpring but for the example I will keep it simple. The index file shows 3 quick examples; a way to get all settings, a way to get 1 setting and how to set a new value and re write the file. Finally the Settings component is in the folder org.danvega. If you want to change the location of this file just make sure to change the return type. Please let me know if anyone has any problems. Enjoy!!!

Comments

#1 Posted By: Bruce Posted On: 1/9/07 4:17 PM
Thanks for posting this example. I figured out the problem I was having in my test. I was calling the read function after doing the init. Since init calls the read function, my call to the read function was forcing the structure to try to add a duplicate key.

You may want to make the read function private since it is supposed to only be called from within the init method. That will prevent calling it from outside the CFC. Also you may want to change output to false for the read method. Lastly you may want to change the hint for the read function which is what I used to figure out if I should call this function or not.

Thanks again.
#2 Posted By: Dan Posted On: 1/9/07 4:20 PM |
Author Comment
Bruce,
Thank you for the feedback! You make some excellent points and I will update the code and repost it. The reason the output was true is because it was never changed from when I was debugging an error. I agree 100% on changing the read method to private though, thanks again for you thoughts.
#3 Posted By: Dan Posted On: 1/9/07 5:23 PM |
Author Comment
I have updated the zip file!


Post Your Comment

Leave this field empty







Show Captcha

If you subscribe, any new posts to this thread will be sent to your email address.

Copyright © 2007 Dan Vega | BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.