Home| faqs| resources| exchange| about
Previous Posts
Log In
Username:

Password:
 
Forgot your password?
Register now >>
Sponsored by
Tracking Tools

On the bookshelf... Bookshelf unavailable

Powered with CFMX

Wednesday, November 10, 2004

function libraries and getProperty() from views

If you've ever had to access a common function library from your views, you're probably using a plugin to create reference to the functions in the properties then injecting the functions into the event object on pre-event. This is discussed in the FAQs.

With v1.0.10, things are a bit more convenient. Most people know that the Plugin, Listeners and Filters extend the new BaseComponent so you can access properties from within those components with getProperty() and setProperty(). What most people haven't noticed is that although the ViewContext doesn't extend BaseComponent, it has its own getProperty() and setProperty() methods. So, if you've set your function library as a property called "functionLib", then you can simply refer to it from a view by

<cfset fl = getProperty("functionLib")/>

and you can skip the pre-event.

0 Comments:

Post a Comment

<< Home