The frontier request flow global events

Learn about handling frontiers events globally

Frontiers were created to allow developers to post data back to the server. A Frontier call is actually an HTTP POST Request to the server with data to be processed.

In the diagram below, you can see exactly how the frontier call flow is :

Assemble call request

Before firing an HTTP request to the server, Hi-Frameworks does the following:

  • Create a jquery ajax request object
  • Set http headers (CSRF protection and others)
  • Format and set frontier call arguments on request object
  • Apply simultaneous calls policy

Simultaneous calls policy

Is the way Hi-framework gives you to configure its behavior regarding simultaneous calls of a specific frontier method. Learn more about it here.


This event is fired twice during a frontier method invocation : before and after the method execution.

Before frontier method execution

If you wish do define some general behavior before a frontier method execution, you just have to check the isAfter() boolean method of the FrontierRequestEvent instance.

See an example below :

 public void preFrontier(@Observes FrontierRequestEvent event){
       //This is before the frontier call


Use this event while developing your app to willingly make it slower by invoking Thread.sleep(milliseconds). It will help you simulate a bad response time scenario.

After frontier method execution

If you wish to define some behavior for after your frontier is called, this is the place. You just have to check the isAfter() boolean method of the FrontierRequestEvent instance.

public void postFrontier(@Observes FrontierRequestEvent event) {
        //This is after the frontier call


Handling errors

If your frontier request fails for some reason, you have a way of handling the errors both on the call and globally. If you read the Getting started section (If, you didn't, please do), you probably know by now how to handle errors in the call.

This topic will only explain how you can handle them globally.

Handling frontier request errors globally

To achieve this goal, you will have to set a catch callback function for the $frontiers object in your template controller.

See an example below :

$frontiers : {

    catch : function(call,error){
       //handle errors here


If you need to learn more about handling frontier errors, please read the tutorial : Catching errors on frontiers.

Finally Block

The same way the finally block is used in Java to make sure a specific code block gets executed even when the enclosed try-catch block throws an Exception, Hi-Framework uses it for Frontier requests. The Finally block on a frontier call can work both on the call and globally.

Global handler for Frontier finally

$frontiers : {
    finally : function(call){

        //handle errors here


If you want to know how frontier's finally block works on a frontier call, please read : Frontiers finally block

Github Repository