Class HtmxResponse

java.lang.Object
io.github.wimdeblauwe.hsbt.mvc.HtmxResponse

public final class HtmxResponse extends Object
Representation of HTMX partials.
Author:
Oliver Drotbohm, Clint Checketts
  • Constructor Details

    • HtmxResponse

      public HtmxResponse()
  • Method Details

    • addTemplate

      public HtmxResponse addTemplate(String template)
      Append the rendered template or fragment.
      Parameters:
      template - must not be null or empty.
      Returns:
      same HtmxResponse for chaining
    • addTrigger

      public HtmxResponse addTrigger(String eventName)
      Set a HX-Trigger header. Multiple trigger were automatically be merged into the same header.
      Parameters:
      eventName - must not be null or empty.
      Returns:
      same HtmxResponse for chaining
      See Also:
    • addTrigger

      public HtmxResponse addTrigger(String eventName, String eventDetail, HxTriggerLifecycle step)
      Set a HX-Trigger (or HX-Trigger-After-Settle or HX-Trigger-After-Swap headers. Multiple trigger were automatically be merged into the same header.
      Parameters:
      eventName - must not be null or empty.
      eventDetail - can be null.
      step - must not be null or empty.
      Returns:
      same HtmxResponse for chaining
      See Also:
    • pushHistory

      public HtmxResponse pushHistory(String url)
      Pushes a new url into the history stack
      Parameters:
      url - must not be null or empty. false prevents the browser history from being updated
      Returns:
      same HtmxResponse for chaining
      See Also:
    • browserRedirect

      public HtmxResponse browserRedirect(String url)
      Can be used to do a client-side redirect to a new location
      Parameters:
      url - can be a relative or an absolute url
      Returns:
      same HtmxResponse for chaining
    • browserRefresh

      public HtmxResponse browserRefresh(boolean refresh)
      If set to "true" the client side will do a a full refresh of the page
      Parameters:
      refresh - boolean to indicate full refresh or not.
      Returns:
      same HtmxResponse for chaining
    • retarget

      public HtmxResponse retarget(String cssSelector)
      Set a CSS selector that updates the target of the content update to a different element on the page
      Parameters:
      cssSelector - must not be null or empty.
      Returns:
      same HtmxResponse for chaining
    • and

      public HtmxResponse and(HtmxResponse otherResponse)
      Parameters:
      otherResponse - Another HtmxResponse that will be merged into this response.
      Returns:
      this for chaining