Monday, 12 August 2019

JET - router defaults and parameters

JET - v7.1.0
Source: GitHub

This is a quick tip on Oracle JET Router configurations. There are a couple of ways through which we can pass parameters while navigating using ojet Router.

1) You can set some global parameters while setting up the router configuration. This parameter is available on the static Router.rootInstance object.

This value can be accessed via the Router's rootInstance's current-state.

Using this value I can set the default tab whenever I enter a module.

2) The second option is to set a dynamic value while programmatically navigating to a module using ojet router. We use the store() method to set a parameter, and the retrieve() method to fetch it. The router param gets written to the URL to let you have a bookmark.

We can make use of this method to set a user-defined value as the default tab when we navigate across different modules.

Remember: there is only one instance of jet router for the application. So when you exit the module, you can make use of the handleDeactivated life-cycle hook and pass an empty object to reset the parameter, so that the parameter is no more available to other modules.

** Refer to the router-tab and playground modules in the GitHub source code.


No comments:

Post a Comment