Yup, that did it. I was using <event-filter> instead of <filter>. I must've i wasnt paying attention when i was reading the doc.
And thanks for the link, i have bookmarked it for future reference. On Dec 16, 11:25 am, "Peter J. Farrell" <[email protected]> wrote: > You can't nest other commands inside an filter command -- they will just > be ignored. Also, the command name is "filter" not "event-filter" when > you declare it in an event-handler: > > <event-handler event="sysadmin.server_setting" access="public"> > <filter name="permissionValidation"> > <parameter name="role_id" value="3" /> > </filter> > <view-page name="sysadmin.act_server_setting"/> > <view-page name="sysadmin.server_setting" contentArg="layout.content" > /> > <execute subroutine="sysadmin.compileLayout" /> > </event-handler> > > For future reference, I'd look at the XML Quick Reference > Guide:http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/ConfigFileExpla... > > And I'd use an XML editor that offers DTD validation so you can use the > DTD that comeswith Mach-II to validate your XML file for validity: > > http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/FAQUsingDTD > > geomunir said the following on 12/16/2009 01:06 PM: > > > > > > > I made the changes, however, it does not seems to be working. First of > > all, i dont see permissionValidation.cfc initiated at all. If its not > > initiating, then sysadmin.accessDenied wont be announced. > > > If i change to something like this, then it does: > > <event-handler event="sysadmin.server_setting" access="public"> > > <event-filter name="permissionValidation"> > > <parameter name="role_id" value="3" /> > > <view-page name="sysadmin.act_server_setting"/> > > <view-page name="sysadmin.server_setting" > > contentArg="layout.content" /> > > <execute subroutine="sysadmin.compileLayout" /> > > </event-filter> > > </event-handler> > > > But, after the change, nothing happens. Blank page is shown. > > > Mike, > > role_id does change, from event to event. > > > On Dec 16, 12:18 am, "Peter J. Farrell" <[email protected]> wrote: > > >> ParamArgs (nested inside your filter when you declare it in an > >> event-handler) are passed. Change: > > >> if(isUserInRole(event.getArg(role_id))) > > >> to > > >> if(isUserInRole(arguments.paramArgs.role_id)) > > >> I'd also clear the event-queue before annnouncing your access denied event: > > >> arguments.eventContext.clearEventQueue(): > > >> Also, you can change this: > > >> arguments.eventContext.announceEvent("sysadmin.accessDenied", > > >> to this: > > >> announceEvent("sysadmin.accessDenied", arguments.event.getArgs()); > > >> AnnounceEvent() is one of the built in methods in the BaseComponent > >> class that MachII.framework.EventFilter inherits from. > > >> HTH, > >> .Peter > > >> geomunir said the following on 12/16/2009 01:36 AM: > > >>> I'm trying to get filter working, but for some reason its not working > >>> as expected. Maybe, something in my logic or i'm not getting the > >>> filter right. > > >>> Whats happening?: Well, I see the event filter is being triggered, but > >>> nothing happens, regular page is displayed. I'm logged in as not > >>> authorized user (role_id=4), and reguired role_id = 3 (parameter). > > >>> When i'm not authorized, i should be redirected to > >>> sysadmin.accessDenied event. > > >>> Here is the code: > > >>> mach-ii.xml > >>> -- > >>> <event-filters> > >>> <event-filter name="permissionValidation" > >>> type="blaz.filters.permissionValidation" /> > >>> </event-filters> > > >>> <event-handler event="sysadmin.server_setting" access="public"> > >>> <event-filter name="permissionValidation"> > >>> <parameter name="role_id" value="3" /> > >>> </event-filter> > > >>> <view-page name="sysadmin.act_server_setting"/> > >>> <view-page name="sysadmin.server_setting" > >>> contentArg="layout.content" /> > >>> <execute subroutine="sysadmin.compileLayout" /> > > >>> </event-handler> > > >>> permissionValidation.cfc > >>> <cfcomponent extends="MachII.framework.EventFilter" hint="Permision > >>> Validation"> > >>> <cffunction name="configure" access="public" output="false" > >>> returntype="void" hint="Configures the filter"> > >>> <!--- Does nothing ---> > >>> </cffunction> > > >>> <!--- Authenticate Specfic Role ---> > >>> <cffunction name="filterEvent" returntype="boolean"> > >>> <!--- Required Arguments ---> > >>> <cfargument name="event" type="MachII.framework.Event" > >>> required="true" /> > >>> <cfargument name="eventContext" > >>> type="MachII.framework.EventContext" required="true" /> > >>> <cfargument name="paramArgs" type="struct" required="false" > >>> default="#StructNew()#" /> > > >>> <cfscript> > >>> //Declare variable and assign initial value > >>> var validationBoolean = false; > > >>> //If logged in user matches with Required role > >>> if(isUserInRole(event.getArg(role_id))) > >>> { > >>> //Assign value to a variable > >>> validationBoolean = true; > >>> } > >>> else > >>> { > >>> //Assign value to a variable > >>> validationBoolean = false; > > >>> //Announce Mach-II Event-Handler > >>> > >>> arguments.eventContext.announceEvent("sysadmin.accessDenied", > >>> arguments.event.getArgs()); > >>> } > > >>> </cfscript> > > >>> <cfreturn validationBoolean> > >>> </cffunction> > > >>> </cfcomponent> > > >> -- > > >> The Harmonious Programmer > >> <http://feeds.feedburner.com/%7Er/TheHarmoniousProgrammer/%7E6/1> > > >> *Peter J. Farrell* > >> Email: [email protected] | p...@maestropublishing > >> Blog: The Harmonious Programmer <http://blog.maestropublishing.com> > >> Twitter/Identi.ca: @maestrofjp > > >> TheHarmoniousProgrammer.1.gif > >> 64KViewDownload- Hide quoted text - > > >> - Show quoted text - > > -- > > The Harmonious Programmer > <http://feeds.feedburner.com/%7Er/TheHarmoniousProgrammer/%7E6/1> > > *Peter J. Farrell* > Email: [email protected] | p...@maestropublishing > Blog: The Harmonious Programmer <http://blog.maestropublishing.com> > Twitter/Identi.ca: @maestrofjp > > TheHarmoniousProgrammer.1.gif > 65KViewDownload- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to Mach-II for CFML list. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/mach-ii-for-coldfusion?hl=en SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/ Wiki / Documentation / Tickets: http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
