Class Render

java.lang.Object
org.apache.juneau.console.views.Render

@BeanType(properties="id,meta,popover") public class Render extends Object
A named cell-renderer reference in the VIEW_META wire contract.

Serializes to the canonical object form {"id":"tag","meta":{"field":"status"}}; the optional meta and popover members are omitted from the wire when unset. The client juneau-renders.js registry looks up id and invokes the matching renderer, passing the meta map through as per-column context (and painting popover, when present, from row data already on the client). Typed factories exist for the renderers that take structured metadata: progress(int) and pill(String). Timestamp renderers (ts-zulu, datetime) honor meta.popup: off disables the local/California hover popup; ts-zulu defaults the popup on, datetime defaults it off.

A compact string sugar is supported via parse(String): everything after the first colon becomes meta.field — e.g. "tag:status" → {id:"tag", meta:{field:"status"}} and "date" → {id:"date"}.

See Also:
Since:
10.0.0
  • Field Details

    • id

      public String id
      The renderer id (registry key in juneau-renders.js).
    • meta

      public Map<String,Object> meta
      Optional per-column renderer metadata. Omitted from the wire when absent.
    • popover

      Optional per-cell popover, omitted from the wire when unset.

      The runtime appends a sibling trigger next to the rendered cell and paints the popover from row data already on the client. Never assigned innerHTML.

  • Constructor Details

  • Method Details

    • of

      public static Render of(String id)
      Creates a renderer reference with the specified id and no metadata.
      Parameters:
      id - The renderer id. Must not be null.
      Returns:
      A new Render.
    • parse

      public static Render parse(String s)
      Parses a render-id string into a Render, applying the "id:field" string sugar.

      Everything after the first colon becomes meta.field; a bare id (no colon) yields a metadata-free renderer.

      Parameters:
      s - The render-id string. Must not be null or blank.
      Returns:
      A new Render.
    • meta

      public Render meta(String key, Object value)
      Adds a metadata key/value pair to this renderer reference.
      Parameters:
      key - The metadata key. Must not be null.
      value - The metadata value. Serialized as given, so a Number or Boolean stays a JSON number or boolean (for example meta("places", 2)).
      Returns:
      This object.
    • popover

      public Render popover(CellPopover value)
      Sets the optional per-cell popover.
      Parameters:
      value - The popover definition. Can be null to unset.
      Returns:
      This object.
    • progress

      public static Render progress(int max)
      Creates a progress renderer with the given maximum (denominator).

      Equivalent to Render.of("progress").meta("max", String.valueOf(max)). Chain meta(String,Object) for label / field.

      Parameters:
      max - The ratio denominator. Serialized as the string meta.max.
      Returns:
      A new Render.
    • progress

      public static Render progress(int max, Integer warn, Integer exceeds)
      Creates a progress renderer with maximum and optional warn/exceeds thresholds.

      warn and exceeds are omitted from meta when null. A boxed 0 is a real threshold ("0"), not omitted.

      Parameters:
      max - The ratio denominator.
      warn - Warn threshold in the same units as the cell value. Can be null.
      exceeds - Exceeds threshold in the same units as the cell value. Can be null.
      Returns:
      A new Render.
    • pill

      public static Render pill()
      Creates a pill renderer with the leading dot on and the tone inherited from the chip theme.

      Equivalent to Render.of("pill"). The dot color follows the .tag.<field>.<value> theme (currentColor) until an explicit tone is chosen. Chain meta(String,Object) for field, dot (on|off) and action (a rowActions id).

      action is optional and only meaningful on a table column: a pill named on a field-grid fill sink is unconditionally display-only and rejects an action outright.

      Returns:
      A new Render.
    • pill

      public static Render pill(String tone)
      Creates a pill renderer with an explicit dot tone.

      tone is one of the five status tones info|success|warning|error|neutral (see StatusTone). A null or blank tone is omitted from meta (identical to pill()); neutral is emitted verbatim and, like an absent tone, leaves the dot inheriting currentColor. The tone is not validated server-side: the client (NS._render.pillTones) ignores an off-palette token, so the dot gets no tone class. Prefer pill(StatusTone) to stay on the palette.

      Not to be confused with progress(int, Integer, Integer)'s warn/exceeds meta, which are numeric thresholds rather than tone names and share no vocabulary with this palette.

      Parameters:
      tone - The explicit dot tone. Can be null or blank to inherit.
      Returns:
      A new Render.
    • pill

      public static Render pill(StatusTone tone)
      Creates a pill renderer with an explicit dot tone taken from the StatusTone palette.

      Equivalent to pill(tone == null ? null : tone.wire()); a null tone is omitted from meta, identical to pill().

      Example:

      // Renders as {id:"pill",meta:{tone:"warning"}}. Render r = Render.pill(StatusTone.WARNING);

      Parameters:
      tone - The explicit dot tone. Can be null to inherit.
      Returns:
      A new Render.