#{extends 'template.html' /}
Welcome to the demo app for the featureflags module for Play!.
This demo only shows the most basic functionality: the ability to enable and disable features at runtime. For more
detailed information, please refer to the documentation on the wiki or the test suite.
A Feature is any piece of functionality in your application that you want to be able to switch on and off at runtime. For the moment, only 'ON' and 'OFF' are supported, but in the future we'll add support for conditional (per environment, user profile, user role, ...) switches.
Features are defined by name. You can (and should, more later) define features in two ways:
To define a feature on an element in your application views, you can use the feature tag, like so:
#{featureflags.feature 'featureName'} <div> ... feature content goes here ... </div> #{/featureflags.feature}
The div and all contents won't be rendered, unless the feature is switched on.
Of course, just hiding a menu item is not enough to completely make it unavailable. Users could have bookmarked the
URL behind the menu item, for example.
In order to disallow access by URL, you can annotate your controller methods:
@Feature("myFeature") public static void myActionMethod(){ // this action is available or not, // depending on whether "myFeature" is // enabled }
You can also annotate a whole controller class, like so:
@Feature("myFeature") public class FeaturedController { // all actions in this controller will be // available or not, depending on whether // "myFeature" is enabled or not. public static void action1(){ } public static void action1(){ } }
Whenever a view containing a feature tag is rendered, or an annotated controller is invoked, the featureflags module will pick this up.
The module will check if the feature is defined in the db. There are three possible scenarios:
Since version 0.2 of the module, the module behaves differently in development and production mode.
When you run your Play! app in development mode, all features will be turned ON by default. This is very convenient, since
you don't want to bothered with switching on features while developing.
You can, of course, still use the admin page to go and switch a feature off if you wish to do so.
However, when in PROD mode, all features that are not known in the db yet, will be switched to OFF by default. This ensures you don't accidentally put features in production that aren't ready yet.
The admin page is provided to you by the module. It shows an overview of the features, their status and a button per feature to switch individual features on and off.
You can view the admin page for this demo app under /admin/features.
Below is an example menu with feature tags. On the left, you see the code, on the right te resulting menu.
Of course, if you just started up this demo application, you won't see any menu items yet. Remember: features are
turned off by default. So feel free to go to the admin page, play around
with the switches and refresh this page to see the result.
<ul id="menu"> #{featureflags.feature 'demoMenu1'} <li>Menu Item 1</li> #{/featureflags.feature} #{featureflags.feature 'demoMenu2'} <li>Menu Item 2</li> #{/featureflags.feature} #{featureflags.feature 'demoMenu3'} <li>Menu Item 3</li> #{/featureflags.feature} #{featureflags.feature 'demoMenu4'} <li>Menu Item 4</li> #{/featureflags.feature} </ul> |