0

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

Sumit Sundriyal
  • 815
  • 1
  • 11
  • 14

1 Answers1

1

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.

    <jsp-config>
       <taglib>
            <taglib-uri>
                /togglz
            </taglib-uri>
            <taglib-location>
                /WEB-INF/tld/togglz.tld
            </taglib-location>
        </taglib>
    </jsp-config>

3. Add taglib in the jsp.

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

4. Test feature class.

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

5. test.jsp.

<togglz:feature name="TEST_TOGGLZ">
  Test Toggle enabled
</togglz:feature>
<togglz:feature name="!TEST_TOGGLZ">
  Test Toggle disabled
</togglz:feature>
Sumit Sundriyal
  • 815
  • 1
  • 11
  • 14