Interface HtmxRequest


public interface HtmxRequest
This class can be used as a controller method argument to access the htmx Request Headers.


   @HxRequest
   @Get("/users")
   String users(HtmxRequest htmxRequest) {
     if (htmxRequest.isBoosted()) {
         ...
     }
   }

 
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder for HtmxRequest.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HtmxRequest
    Represents a non-Htmx request.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return a new builder for the HtmxRequest.
    Return the current URL of the browser when the htmx request was made.
    boolean
    Indicates that the request is via an element using hx-boost.
    boolean
    Indicates if the request is for history restoration after a miss in the local history cache
    boolean
    Return true if this is an Htmx request.
    Return the user response to an HX-Prompt.
    Return the id of the target element if it exists.
    Return the id of the triggered element if it exists.
    Return the name of the triggered element if it exists.
  • Field Details

    • EMPTY

      static final HtmxRequest EMPTY
      Represents a non-Htmx request.
  • Method Details

    • builder

      static HtmxRequest.Builder builder()
      Return a new builder for the HtmxRequest.
    • isHtmxRequest

      boolean isHtmxRequest()
      Return true if this is an Htmx request.
    • isBoosted

      boolean isBoosted()
      Indicates that the request is via an element using hx-boost.
      Returns:
      true if the request was made via HX-Boost, false otherwise
    • currentUrl

      @Nullable String currentUrl()
      Return the current URL of the browser when the htmx request was made.
    • isHistoryRestoreRequest

      boolean isHistoryRestoreRequest()
      Indicates if the request is for history restoration after a miss in the local history cache
      Returns:
      true if this request is for history restoration, false otherwise
    • promptResponse

      @Nullable String promptResponse()
      Return the user response to an HX-Prompt.
    • target

      @Nullable String target()
      Return the id of the target element if it exists.
    • triggerName

      @Nullable String triggerName()
      Return the name of the triggered element if it exists.
    • triggerId

      @Nullable String triggerId()
      Return the id of the triggered element if it exists.