Class HandlerRef

java.lang.Object
org.apache.juneau.console.HandlerRef

public final class HandlerRef extends Object
A reference to a client-side handler: a registered name or an opt-in inline body.

Names use the ns.name grammar and are registered on the page with JuneauViews.handlers.register. The juneau.* namespace is reserved for the built-ins (see builtin(String)).

Example:

HandlerRef a = HandlerRef.named("orders.refresh"); HandlerRef b = HandlerRef.builtin("refresh"); // juneau.refresh

Since:
10.0.0
  • Method Details

    • named

      public static HandlerRef named(String name)
      A registered handler name.
      Parameters:
      name - The name, e.g. orders.refresh. A juneau.-prefixed name is accepted only when it names a built-in.
      Returns:
      A new reference.
      Throws:
      IllegalArgumentException - If the name is malformed or uses the reserved namespace.
    • builtin

      public static HandlerRef builtin(String name)
      A built-in handler.
      Parameters:
      name - The built-in name without prefix, e.g. refresh.
      Returns:
      A reference to juneau.<name>.
      Throws:
      IllegalArgumentException - If the name is not a built-in.
    • inline

      public static HandlerRef inline(String body)
      An inline handler body, compiled on the client as function(target, event). Needs PageSpec.allowInlineHandlers(true).
      Parameters:
      body - The function body.
      Returns:
      A new reference.
      Throws:
      IllegalArgumentException - If the body is blank.
    • name

      public String name()
      Returns the handler name.
      Returns:
      The name, or null for an inline reference.
    • isInline

      public boolean isInline()
      Returns whether this is an inline body.
      Returns:
      true if inline.
    • toJson

      public Object toJson()
      Returns the contract JSON form.
      Returns:
      The name string, or {"inline": body}.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object