Sumit Sundriyal Sumit Sundriyal - 8 months ago 84
Java Question

How to check active and inactive status of a togglz in a jsp?

I want to check active and inactive status of a toggle in a jsp.


Here is the complete example.

1. Download togglz-jsp-x.x.x.jar and put it into the classpath of your project OR copy togglz.tld to /WEB-INF/tld directory.

2. web.xml.


3. Add taglib in the jsp.

<%@ taglib prefix="togglz" uri="/togglz" %>

4. Test feature class.

public enum TestFeatures implements Feature {
  @Label("Test togglz")
  public boolean isActive() {
    return FeatureContext.getFeatureManager().isActive(this);

5. test.jsp.

<togglz:feature name="TEST_TOGGLZ">
  Test Toggle enabled
<togglz:feature name="!TEST_TOGGLZ">
  Test Toggle disabled