Blog

Configuration Manager Actionpack

There has been a lot of talk lately about various ways of configuring applications. There’s newly available Config.cfc which has a nice intro in the comments on Peter Bells post about XML Configuration files ; which also is worth reading. I’m split on this actually. I like how fast you can start up a project using config xml files, but I think the database and corresponding tools to manage the configuration settings is what would be required to have soemone else manage it. As easy as it is for a coder to change an xml file, it’s not always the coder working with the software. I’ve always loved how with phpBB, or wordpress there are little forms you fill out to get started then everything else is through web pages. You can’t store the more complex objects like this of course(not in a standardized way i mean), but simple key/pair values in a database are trivial. Think I’ll try to give that a go tomorrow, but for today is the XML version! My first attempt at a Model Glue actionpack is about as easy as can be. I think configuration for this pack is more lines than the actual pack- – really. Basically it’s a simple way of passing in ModelGlue.core.SimpleConfig objects to a manager object that stuffs them all into the viewstate. From what I’ve seen reading over other code it seems like a good enough way of handling it most the time. A ModelGlue.core.SimpleConfig object can be just about anything — array, structure, simple values, and looks like any combination. The way this works is just by adding in a line to your ModelGlue.xml file like…

And then the big addition comes in your Coldspring.xml file. [xml] Some site title Some site tagline here. Flash haloblue yes no [/xml]Having a bean named ConfigManager is really the only requirement here. If the actionpack is included without that bean set it’ll give an error when the first page is called. By default autowiring setConfigManager will be called on modelglue.actionpack.xmlconfig.Controller.ConfigController with this bean (the structure of config objects). Change the constructor arguments to take in bean references for anything you want available in your viewstate. Whatever you have in the entry-key value in the ConfigManager object will be what you reference it by in the viewstate. For instance, SiteConfiguration here would be accessible through viewState.getValue(“SiteConfiguration”) and the FormConfiguration would be accessible through viewState.getValue(“FormChangedExample”). This will return the SimpleConfig Object, which can then be converted into a structure, or just worked with through the SimpleConfig methods. It’s available now in the public repository at http://svn.adamfortuna.com/public/ModelGlueDev/ . What it comes down to is being able to access those values in the viewstate easily enough… [cfm] Model-Glue is up and running! [/cfm] Will generate this…

Avatar for Adam Fortuna

Hey hey! đź‘‹

I'm , a full-stack product developer in Salt Lake City, UT. I love enlivening experiences, visualizing data, and making playful websites.

Let's keep in touch 🧑‍🤝‍🧑

Did you link to this article? Add it here