I just upgraded to Coldbox 3.1 from 2.5.2 and now I'm bouncing between
I have an event handler that includes a file (some of which contain
functions) via a cfinclude. For example, one page includes a file with
a function called "printOut". After a reinit, the page loads fine the
first time. But upon trying to reload it, I get the error "Routines
cannot be declared more than once. The routine printOut has been
declared twice in different templates."
If I turn off handler caching in the config, this error goes away, but
then I get a lot of "Element VIEWPATH is undefined in VIEWLOCATIONS"
errors. If I turn on handler caching, I've noticed the "Viewpath"
errors go away, but then I get this "duplicate routine" error on any
page that has it's own functions.
Maybe you could move that function into a helper?? I'm no ColdBox
guru, but I'd lose the cfinclude.
Check the docs on "helpers"
As Malik suggested ColdBox provides you with an easy way to centralize UDF’s with the setting:
UDFLibraryFile = “includes/helpers/ApplicationHelper.cfm”,
You can place all of your UDF’s in that file and they will be accessible throughout your app. I’ve only tested accessing the UDF’s within views and handlers. I’m not sure if they are available in models, etc.
Yeah, that's kinda the solution I've been left with trying. And I
should have them all in a central UDF anyway, I guess this is what'll
force me to put all my functions there.
I just wish I knew why it stopped working with the upgrade, I think it
has something to do with handler caching since it loads fine the first
time the page loads, it loads find with no double-call.
I found one thread about the "Element VIEWPATH is undefined in
VIEWLOCATIONS" error possibly occuring right after a reinit, but it's
occuring long after any reinits.