[coldbox 3.8.1] Override event or view in Handlers preHandler() method

267 views
Skip to first unread message

Jason Morris

unread,
Aug 13, 2014, 12:25:56 AM8/13/14
to col...@googlegroups.com

I want to run a preHandler AOP method on a handler which checks to see if user can access this handler, and if not, give them a message that they can't.

My current handler is below.. from what I can tell working through the Coldbox Docs, this should do what I am trying to do, but when I access the 'main' action, it is showin the main view, but I would expect the preHandler to  override this and show me the noaccess view (via the noaccess method).

Can anyone see what I might be doing wrong?

Thanks



component output="false" extends="_handlers"{

       //Pre Handler

       public function preHandler(event,action,eventArguments){

               var memberDenied = true;

               if (memberDenied)                      
                     event.overrideEvent('_cpd.noaccess');

       }


        //Main

       public function main(event,rc,prc){

              //display main page

       }

        //No Access

       public function noaccesss(event,rc,prc){

               //display no access page


        }


}





br...@bradwood.com

unread,
Aug 13, 2014, 12:49:49 AM8/13/14
to col...@googlegroups.com
I just tried it in a test handler and it works as expected.  I put these three methods in my main.cfc handler and when I hit main.index, I it outputs "boo!" as though I'd hit main.boo.

<cffunction name="preHandler">
  <cfset event.overrideEvent('main.boo')>
</cffunction>

<cffunction name="index">
  <cfset event.setView(view="main/index")>
</cffunction>

<cffunction name="boo">
  <cfreturn "boo!">
</cffunction>

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
Subject: [coldbox:22092] [coldbox 3.8.1] Override event or view in Handlers preHandler() method
From: "Jason Morris" <jason.mor...@gmail.com>
Date: 8/12/14 11:25 pm
To: col...@googlegroups.com

 
I want to run a preHandler AOP method on a handler which checks to see if user can access this handler, and if not, give them a message that they can't.
 
My current handler is below.. from what I can tell working through the Coldbox Docs, this should do what I am trying to do, but when I access the 'main' action, it is showin the main view, but I would expect the preHandler to  override this and show me the noaccess view (via the noaccess method).
 
Can anyone see what I might be doing wrong?
 
Thanks
 
 

componentoutput="false"extends="_handlers"{

       //Pre Handler

       publicfunctionpreHandler(event,action,eventArguments){

               var memberDenied = true;

               if (memberDenied)                      
                     event.overrideEvent('_cpd.noaccess');

       }


        //Main

       publicfunctionmain(event,rc,prc){

              //display main page

       }

        //No Access

       publicfunctionnoaccesss(event,rc,prc){

               //display no access page


        }


}



 
 

 

--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages