Class BadgeDirectiveModel

java.lang.Object
org.apache.juneau.console.freemarker.BadgeDirectiveModel
All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel

public final class BadgeDirectiveModel extends Object implements freemarker.template.TemplateDirectiveModel
The <@badge> FreeMarker twin of PageSpec.badge(BadgeDef): every scalar or enum BadgeDef field is a plain attribute (the label templates as labelOne, labelOther and labelMine, the scope as scopeParam and scopeBy, the state filter as stateFilterColumn). The three structured fields have no flat shape, so an optional JSON5 body supplies them under the keys visibleWhen (a rule list), scopeValues (a map of nav node id to value list) and params (a map). Any other body key is rejected.

The FTL scope is stricter than BadgeDef.scope(java.lang.String, org.apache.juneau.console.views.BadgeDef.ScopeBy, java.util.Map<java.lang.String, java.util.List<java.lang.String>>): scopeParam and scopeBy must be given together, and scopeBy must be spelled nav or view, where the Java form defaults a missing by to nav.

Example:

<@badge id="health" src="/rest/health" refreshMs=30000 tone="warning"> {"visibleWhen": [{"field": "status", "op": "eq", "value": "degraded"}]} </@badge>

Since:
10.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The shared-variable name this directive registers under.

    Fields inherited from interface freemarker.template.TemplateModel

    NOTHING
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • execute

      public void execute(freemarker.core.Environment env, Map params, freemarker.template.TemplateModel[] loopVars, freemarker.template.TemplateDirectiveBody body) throws freemarker.template.TemplateException, IOException
      Specified by:
      execute in interface freemarker.template.TemplateDirectiveModel
      Throws:
      freemarker.template.TemplateException
      IOException