How to execute subroutines from filters

2 views
Skip to first unread message

vience

unread,
Jul 3, 2008, 2:49:43 AM7/3/08
to Mach-II for ColdFusion
I have created some subroutine to cache permision data and some
filters to check user access, is there any possible to call subroutine
in a filter?

My current Code as follow:

<event-handler event="currentSession" access="public">
<execute subroutine="getSessionPermisionInfo" />
<execute subroutine="getEventGroupPermision" />
<filter name="permisionFilter" />
<execute subroutine="getSessionInfo" />
<view-page name="ids:currentSession" contentArg="pageContent" />
<execute subroutine="applyTemplate"/>
</event-handler>

"You can execute subroutines from plugins and filters, but cannot
execute them from within listeners. This is similar to not being able
to clear the event queue from the listener, whereas you can clear the
event queue from a filter or plugin." I found this notice in Mach-II
Office WIKI, can anybody show me example to call subroutes in filter.?

sli...@gmail.com

unread,
Jul 8, 2008, 6:02:12 PM7/8/08
to Mach-II for ColdFusion
http://greatbiztoolsllc-trac.cvsdude.com/mach-ii/wiki/Documentation

Be, to check out the documentation available in the link above. The
API documentation can be very helpful if you know how to understand it
(it took me a while).
If you look at an example plugin you will see that each plugin point
takes the eventContext object as an argument. Knowing that, you can
take a look at the API documentation to see what functions are
available to you there. So clicking on the eventContext object, almost
at the top you can see there is a executeSubroutine() funciton. This
function takes a string as the first parameter, which is the name of
the subroutine, and the second parameter must be an event object.
Probably you will give it the current executing event. So executing a
subroutine may look something like this:

<!--- This gets the current event object --->
<cfset currentEvent = ARGUMENTS.eventContext.getCurrentEvent()>
<!--- This executes the subroutine --->
<cfset
ARGUMENTS.eventContext.executeSubroutine('mysubroutine',currentEvent)>

Keep in mind your variables really need to be var scoped. Hope this
helped!

sli...@gmail.com

unread,
Jul 8, 2008, 6:03:59 PM7/8/08
to Mach-II for ColdFusion
also, if you haven't I recommend you spend some time taking a look at
the FAQ section.

On Jul 3, 1:49 am, vience <vience....@gmail.com> wrote:

vience

unread,
Jul 10, 2008, 12:27:25 AM7/10/08
to Mach-II for ColdFusion
Thanks for your example to help me working out.

I was thinging about there maybe a function like 'announce' for
calling subroutine easily. :)
> > Office WIKI, can anybody show me example to call subroutes in filter.?- 隐藏被引用文字 -
>
> - 显示引用的文字 -
Reply all
Reply to author
Forward
0 new messages