Gentlemen,
Please be patient with me, I am a new ColdBox user. Some concepts used here are new and foreign to me, so if you point me at the good examples or direct me to the appropriate documentation, I can probably pick up what I need. Most of my background in CF using frameworks. was using Fusebox.
I am in the process of trying to build a new ColdBox application with Chad Baloga, who is also on the forums; we both are tackling different issues in creating the app.
In an effort to handle a fairly complex navigation system that the app requires, I am building a navigation object, that will handle it.
I had intended to set it up so that the base object was an interface that is instantiated when the app is fired up.
I would have done this simply as a
application.nav = new models.m_navigation();
then, to configure the navigation, I would execute the methods to do whatever they need to do…
application.navigation.addNavBar(‘adminNavbar’,{type=‘tabs’,id= ‘navbar1’,ul_class = ‘nav nav-tabs’,class = ‘’});
application.navigation.addNavBar(‘userNavbar’,{type=‘tabs’,id= ‘navbar2’,ul_class = ‘nav nav-tabs’,class = ‘’});
and so on.
Ultimately, the idea would be to call a method later, say in a view or a layout file, to display the navigation, rendered where needs to be, however it needed to look:
#application.navigation.render(‘userNavbar’).text#
I have been trying to figure out how I would accomplish the same thing in ColdBox, without leaving it as just a plain ole application variable, which has it’s own problems… mainly, the fact that fwreiniting doesnt reload the application var i created in the first place. I know there is a way to trigger events with fwreinit, and maybe that’s the simple answer here.
I tried it in Wirebox, and the main loading I can do… and works fine. But, after it’s in Wirebox, setup, say like this:
map(“navigation”).to(“models.m_navigation”);
I could figure out how to inject it into the handlers:
But, I couldn’t figure out how I do the step between the instantiation at the beginning, and the first use of it… where it triggers the sequence of steps it needs to actually set it up before I use it the first time.
I looked at using it as a module… I actually set it up in a requestDecorator to add the module to the PRC, so I can refer to it in my views.
So, I thought I would trigger the setup sequence in the moduleConfig. I emulated the way the cbscrf and cbdebuger modules are setup; they both call a parseParentSettings function, so I did the same thing:
private function parseParentSettings(){
var oConfig = controller.getSetting( “ColdBoxConfig” );
var configStruct = controller.getConfigSettings();
var navigation = oConfig.getPropertyMixin( “navigation”, “variables”, structnew() );
//defaults
configStruct.navigation = new models.m_navigation();
include “models\navdocs\default.cfm”;
// Incorporate settings
structAppend( configStruct.navigation, navigation, true );
}
Where the include loads the configuration file up.
However, after the module is configured and the system loads up, when I go to access the module, it returns empty structures… as if it wasn’t configured at all.
What am I missing?? Please tell me there is some obvious thing I am just overlooking…
If you read all that… THANKS.
Robert Bartlett