Class CardSpec

java.lang.Object
org.apache.juneau.console.freemarker.CardSpec

public final class CardSpec extends Object
Type-agnostic card entry in the page contract: id, type, optional src, title, template, plus a type-specific body map. C2 extends the card grammar.
Example:

CardSpec c = CardSpec.html("intro").title("Welcome").template("intro"); CardSpec t = CardSpec.of("datatables", "releases") .body("table", "/rest/releases/data"); PageCapture.of(env).addCard(c, "<p>Hello</p>");

Since:
10.0.0
  • Method Details

    • html

      public static CardSpec html(String id)
      Parameters:
      id - The card id. @return A new html card.
    • of

      public static CardSpec of(String type, String id)
      Parameters:
      type - The card type. @param id The card id. @return A new card.
    • title

      public CardSpec title(String v)
      Parameters:
      v - The card title. @return This object.
    • src

      public CardSpec src(String v)
      Parameters:
      v - A same-origin URL the card loads. @return This object.
    • template

      public CardSpec template(String templateId)
      Parameters:
      templateId - The id of a <template data-card> element. @return This object.
    • bare

      public CardSpec bare(boolean v)
      Parameters:
      v - Whether the card drops its chrome: an html card is inserted with no wrapper element, any other type keeps a wrapper element (class jc-card-bare instead of jc-card) but loses the card chrome and its title.
      Returns:
      This object.
    • sanitize

      public CardSpec sanitize(boolean v)
      Parameters:
      v - Whether an html card's fetched src fragment is rebuilt through the views attribute-allowlist sanitizer instead of being inserted as-is. @return This object.
    • cssClass

      public CardSpec cssClass(String v)
      Parameters:
      v - Space-separated CSS class names stamped on the card wrapper element. @return This object.
    • body

      public CardSpec body(String key, Object value)
      Parameters:
      key - A type-specific field. @param value Its value. @return This object.
    • publishes

      public CardSpec publishes(TopicDecl... v)
      Declares custom topics this card's JS publishes; repeatable, appends.
      Parameters:
      v - The declarations; each needs retain and must not set publisher.
      Returns:
      This object.
    • visibleWhen

      public CardSpec visibleWhen(VisibilityRule... rules)
      Sets card-level visibility rules. The client evaluates them against the page's facts; this only serializes them.
      Parameters:
      rules - The rules, ANDed together. None clears them.
      Returns:
      This object.
    • subscribes

      Wires topics to roles this card's type implements; repeatable, appends.
      Parameters:
      v - The subscriptions.
      Returns:
      This object.
    • id

      public String id()
      Returns:
      The id.
    • type

      public String type()
      Returns:
      The type.
    • bodyMap

      public Map<String,Object> bodyMap()
      Returns:
      An unmodifiable copy of the type-specific body fields, in insertion order.
    • toMap

      public Map<String,Object> toMap()
      Returns:
      The contract entry, common fields first.