Pre Advices
With this interceptor you can intercept local event actions and execute things before the requested action executes. You can do it globally by using the preHandler() method or targeted to a specific action pre{actionName}().
1
// executes before any action
2
function preHandler( event, rc, prc, action, eventArguments ){
3
}
4
5
// executes before the list() action ONLY
6
function preList( event, rc, prc, action, eventArguments ){
7
}
8
9
// concrete example
10
function preHandler( event, rc, prc, action, eventArguments ){
11
if( !security.isLoggedIn() ){
12
event.overrideEvent( 'security.login' );
13
log.info( "Unauthorized accessed detected!", getHTTPRequestData() );
14
}
15
}
16
function preList( event, rc, prc, action, eventArguments ){
17
log.info("Starting executing the list action");
18
}
Copied!
The arguments received by these interceptors are:
  • event : The request context reference
  • action : The action name that was intercepted
  • eventArguments : The struct of extra arguments sent to an action if executed via runEvent()
  • rc : The RC reference
  • prc : The PRC Reference
Here are a few options for altering the default event execution:
  • Use event.overrideEvent('myHandler.myAction') to execute a different event than the default.
  • Use event.noExecution() to halt execution of the current event
See the RequestContext documentation for more details.

Exceptions & Only Lists

You can fine tune these interception methods by leveraging two public properties in the handler:
  • this.prehandler_only : A list of actions that preHandler() will ONLY fire on
  • this.prehandler_except : A list of actions that preHandler() will NOT fire on
1
// only fire for the actions: save(), delete()
2
this.prehandler_only = "save,delete";
3
// DO NOT fire for the actions: login(), doLogin(), logout()
4
this.prehandler_except = "login,doLogin,logout"
Copied!
Last modified 2yr ago
Copy link
Edit on GitHub