Application Startup

Application initialization must be implemented in the Startup class. Custom code that is executed when the application shuts down can be defined here (this is not mandatory). This custom code can be used to empty the cache or free up resources.

The Startup class offers the following options, which are executed in the same order as they are described here. Each option has its own method within the class. If you wish to use these options, implement the corresponding method(s).

Before framework initialization

The beforeFrameworkInitialization() method is executed before the framework starts. Any operation that needs to be executed before the framework starts up can be implemented here. Note that none of the framework’s services are available at this point and they cannot be used.

Parameters

The JBStrap parameters can be set with this method. These parameters affect the general operation of the framework. Setting these parameters can be done anywhere within the application, but it is recommended that you do it here, so that the code can be readable. Previously, we discussed how to set some of the basic application parameters, such as the application title and entry point, in our step-by-step guide . If you would like to see a list of all the available parameters, visit our Javadoc ,

Loading plugins

JBStrap plugins can be loaded and initialized here. To read more about plugins, and on how to use them, see the Working with JBStrap plugins page.

Application initialization

The application can be initialized here. The framework’s services are available at this point, they can be used, along with every loaded plugin. The DataDescriptors can be loaded and used as well. Caches should be loaded here, necessary resources should be opened here.

Creating FileStores

File stores used by the application can be created here. Creating a file store is actually a rather simple process, all it means is that you are assigning a logical name to a physical folder. You can then use this name to refer to the folder. File stores can be created anywhere within the application, but it is recommended that you do it here, so that the code can be readable. To read more about FileStores, see the related article .

Creating Pages

Pages to be used by the application need to be created first, then assigned to the framework. Individual pages are not instantiated yet, they will only be assigned a page ID. During navigation, this page ID can be used to reference the pages.

When creating pages, the UI where the page will be displayed must be specified. If a page is to be displayed on multiple UIs, then the page must have multiple, unique page IDs. Additionally, the pages can have specified parameters that will be used as their default parameters. Parameters can also be specified upon opening pages. To learn more about building pages in JBStrap, see the related article .

Creating Menus

Menus must be defined in the JBStrap framework. Metadata here can be used to build the NavBar and MenuBar components. Multiple menus can be created that can be referenced by their names. See the related article to read more about menus.

As a first step, the menu must be created. To do this, specify a name. The created menu can have menu items assigned to it that can be navigation items, or custom menu items.

The Navigation menu item

Navigation menu items open pages automatically. These menu items cannot have event handlers added to them manually, they are added automatically.

Custom menu items

Custom menu items have their own custom click event handlers. These menu items do not have the page opener event handlers added to them. Thus, if you want to open a page with a custom menu item, the menu item’s event handler must have these implemented.

After initialization

This method runs after the application has been initialized. Processes that run after the initialization should be implemented here.

Shutdown

The shutdown method runs when the application shutdown is initiated. Processes that need to be executed during the shutdown should be implemented here. (e.g. freeing up used resources).

If the application shutdown encounters a problem and cannot shut down properly, the application server won’t be able to close the application either. Thus, this method will not be called. This could happen in case of a power outage, or if there is something is wrong with the server.

Example

The following is an example for a complete application startup