Class RowDetail

java.lang.Object
org.apache.juneau.console.views.RowDetail
All Implemented Interfaces:
Handled<RowDetail>

public final class RowDetail extends Object implements Handled<RowDetail>
Row-detail panel for a table: the per-row GET endpoint, title template, icon and the row-detail region.

CONTRACT_VERSION and response(Object) describe the JSON that endpoint returns.

Example:

table.detail(RowDetail.create("/rest/work/data/{id}") .title("{workId}").icon("search") .region(RegionDef.create("work-detail").populate("work-detail") .allowPopulators("work-detail"))); // The matching endpoint: @RestGet(path="/data/{id}") public JsonMap detail(@Path String id) { return RowDetail.response(store.fields(id)); }

Since:
10.0.0
  • Field Details

  • Method Details

    • modelBlock

      Description copied from interface: Handled
      Returns the element's model block.
      Specified by:
      modelBlock in interface Handled<RowDetail>
      Returns:
      The block; never null.
    • self

      public RowDetail self()
      Description copied from interface: Handled
      Returns this builder.
      Specified by:
      self in interface Handled<RowDetail>
      Returns:
      This object.
    • create

      public static RowDetail create(String endpoint)
      Starts a row-detail definition for the given per-row GET endpoint.
      Parameters:
      endpoint - A same-origin path template carrying the literal {id} row-id placeholder (the client substitutes only that), e.g. "/rest/work/data/{id}". Must not be null or blank.
      Returns:
      A new RowDetail.
      Throws:
      IllegalArgumentException - If endpoint is not a same-origin path with the literal {id} placeholder.
    • inline

      public static RowDetail inline()
      Starts a tabbed detail fed from the clicked row's own data, with no server round trip.

      The row data includes columns hidden by default. A column that must not reach the browser must not be in the rows endpoint.

      Returns:
      A new RowDetail.
    • fromBean

      public static <T> RowDetail fromBean(Class<T> type, Function<String,T> lookup)
      Starts a tabbed detail served by RowDetailMixin from a bean.
      Type Parameters:
      T - The bean type.
      Parameters:
      type - The bean class; only its readable, non-ignored properties can be served.
      lookup - Finds the bean for a row id, or returns null when there is none.
      Returns:
      A new RowDetail.
    • copy

      public RowDetail copy()
      Returns an independent copy, so a shared instance can be attached to several tables.
      Returns:
      The copy.
    • action

      Adds a header action, shown right-aligned in the detail header.
      Parameters:
      a - The action.
      Returns:
      This object.
    • tab

      public RowDetail tab(DetailTab t)
      Adds a tab.
      Parameters:
      t - The tab. Its id must be unique in this detail.
      Returns:
      This object.
    • section

      public RowDetail section(String tabTitle, String... fields)
      Adds a fields tab.
      Parameters:
      tabTitle - The tab title.
      fields - The row fields shown.
      Returns:
      This object.
    • fields

      public RowDetail fields(String... names)
      Narrows the fields the generated Details tab shows.
      Parameters:
      names - The field names.
      Returns:
      This object.
    • columns

      public RowDetail columns(int n)
      Sets the default grid column count of the fields tabs.
      Parameters:
      n - The count, 1 to 4 (default 2).
      Returns:
      This object.
    • label

      public RowDetail label(String field, String text)
      Sets an explicit label for a field. It wins over the column label and the bean metadata.
      Parameters:
      field - The field name.
      text - The label.
      Returns:
      This object.
    • counts

      public RowDetail counts(String value)
      Sets a dedicated endpoint for the tab counts. Without it the counts ride the detail response.
      Parameters:
      value - A same-origin path template carrying {id}.
      Returns:
      This object.
    • cache

      Sets how tab content is cached.
      Parameters:
      value - The policy (default DetailTab.Cache.PER_ROW).
      Returns:
      This object.
    • key

      public RowDetail key(String value)
      Sets the URL key of a bean-backed detail (default: the decapitalised simple class name).
      Parameters:
      value - The key.
      Returns:
      This object.
    • basePath

      public RowDetail basePath(String value)
      Sets the path of the resource that serves a bean-backed detail through RowDetailMixin.

      The endpoint becomes {basePath}/row-detail/{key}/{id}. Without it the endpoint is relative to the site root.

      Parameters:
      value - A same-origin path with no placeholders, e.g. "/console/pets".
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If value is not a safe same-origin path.
    • title

      public RowDetail title(String template)
      Sets the detail panel's title template.
      Parameters:
      template - A row-data interpolation template, e.g. "{workId}". Can be null to unset.
      Returns:
      This object.
    • icon

      public RowDetail icon(String name)
      Sets the detail panel's icon.
      Parameters:
      name - A glyph name resolved by the shared icon registry. Can be null to unset.
      Returns:
      This object.
    • region

      public RowDetail region(RegionDef value)
      Sets the detail panel's region.
      Parameters:
      value - The region. Can be null to clear it (a header-only panel). Its RegionDef.type defaults to RegionDef.TYPE_ROW_DETAIL and its RegionDef.dataUrl defaults to this detail's own endpoint, applied at toMap() time onto a copy; this method never mutates value itself.
      Returns:
      This object.
    • response

      public static JsonMap response(Object fields)
      Builds the detail GET endpoint's own JSON response (not the card fragment).
      Parameters:
      fields - The row's detail fields, a map (or bean) in whatever shape the detail region's populator/renderer expects.
      Returns:
      {contractVersion, fields}.
    • toMap

      public JsonMap toMap()
      Builds this detail's card-body entry: {endpoint, title?, icon?, region?}.

      The region is optional: a detail with none is a header-only panel (the client fills the title/icon header from the endpoint's fields) and the entry carries no region key.

      When a region is set, builds from a copy: reads RegionDef.toContractMap() off the caller's region into a fresh map, applies the type/dataUrl defaults onto that copy, and strips the copy's contractVersion key (a card fragment never nests a contractVersion, since the client stamps it on mount). The caller's RegionDef instance is never written to.

      Returns:
      The detail entry.