How to reset or restart a feature in Oracle MAF?


The navigation bar in Oracle MAF is a very convenient way to display your application features in a MAF application. You enable the navigation bar in the applications maf-application.xml
Adding features to MAF application with navigation enabled shows the feature navigation bar with the feature name and any image that was setup in maf-feature.xml.
As of MAF 2.4, there is some new api available that allows the developer to “restart” a feature as required. Before version 2.4, the only way to restore the state of a feature was to use the “reset” api. The basic difference between the two is that resetting a feature reloads all classes and javascript plugins. This is not the case in a feature restart making it faster than a reset.
I will describe a simple use case which demonstrates why a feature restart may be required. Let’s say you have an application with 2 features and you have enabled the navigation bar. When you run this application, it looks like this:
Let’s say that each of these features initiates a task flow with more than one screen. While you navigate within a feature, it is very easy for a user to switch the feature by selecting another feature from the navigation bar. If you switch back to the previous feature again, you are displayed the same screen in the taskflow that you originally left. So, for eg, Lets say you perform the following actions:
1. Select Feature 1 (3 screens ) and you navigate to screen 3
2. Select Feature 2 (2 screens) and navigate to screen 2
3. Switch back to feature 1. You will land on screen 3.
4. Switch back to feature 2. You will land on screen 2.
This may be acceptable in some cases. But if you want to have the feature always start at the beginning of the task flow every time a feature is selected in the navigation bar, this default behaviour does not work. This is where a feature “reset” or “restarted” comes in.
The following code has helped me customize feature navigation behaviour. Start by defining LifeCycle listeners in the maf-feature.xml. You can create a simple java class like:

Associate this class with the correct feature in maf-feature.xml like:
When you run this application, feature 1 will be restarted every time feature 2 is deactivated.
Let’s take another example. The task flow associated with Feature 1 is a wizard where the user navigates multiple screens to complete a task. You want to provide a button on each screen of the wizard to clear all data entered in the process till now and re-initialize the wizard, you can use a feature restart, instead of a feature reset.
In this case, the command button on each screen that restarts the wizard would look like:

AMX page:

Managed Bean Code:

Hope this helps in understanding the navigation behaviour in MAF. Sample application code can be downloaded here:


Official Docs for Application Navigation in Oracle MAF.
Javadoc for FeatureLifeCycleListener and AdfmfContainerUtilities.queueNavigationRestart



Oracle Fusion Middleware Architect at FUSION Applied
Vivek is an Oracle Certified Fusion Middleware architect. He has over 18 years of experience implementing custom software solutions in the Financial, Health, and Government sectors. He is one of the founders of Fusion Applied.

Leave a Reply

Be the First to Comment!

Notify of