Thursday, November 08, 2007

onMissingMethod clarification

I few days ago, I posted a question regarding the use of the new "onMissingMethod" capability in cf8. I was trying to put together a simple bean and utilize the onMissingMethod to create all purpose getters and setters (in my case the setters are really three methods, 2 of which I wanted to use the onMissingMethod to handle). I had a problem in that onMissingMethod would not fire if I called another method in the same component. A basic example would be calling the setter from inside the init() method in order to exercise my business rules when the object is created. Since the method didn't exist, cf would throw an error.

Thanks to Sean Corfields comment about using the "this" scope for the internal method calls, I was able to get it to work the way I wanted. While I think my particular implementation adds a bit of overhead (not due to the onMissingMethod use), I don't think it will have a huge impact, so I willing to give it a shot until it proves to be a problem.

My code is a little rough at the moment, but when I get it cleaned up a bit, I'll post a sample and probably add a template or two to cfcBlaster.

2 comments:

  1. You may want to take a look at "dynamic bean" that's posted on riaForge.

    http://dynamicbean.riaforge.org/

    Very similar to what you are working on.

    ReplyDelete
  2. Hi,
    I have posted a simple example on onMissingmethod here.

    http://cf-examples.net/index.cfm/2008/8/25/onMissingMethod-Example

    ReplyDelete