Sometimes you need to configure and keep some values in the application for the duration of application life cycle. Use AppContext for this. In order to set the values to the AppContext, write some code in the AppBootstrap:

1
2
3
4
5
public class AppBootstrap extends Bootstrap {
    public void init(AppContext context) {
        context.set("app_name",  "Best App Ever");
    }
}

Once this is done, you can access the context from any controller filter or controller:

1
2
3
4
5
public class HomeController extends AppController {
    public void index(){
         view("app_name",    appContext().get("app_name"));
    }
}

How to comment

The comment section below is to discuss documentation on this page.

If you have an issue, or discover bug, please follow instructions on the Support page