Class HtmxResponse.Builder
java.lang.Object
io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxResponse.Builder
- Enclosing class:
- HtmxResponse
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand(HtmxResponse otherResponse) Merges anotherHtmxResponseinto this builder.build()location(HtmxLocation location) Allows you to do a client-side redirect that does not do a full page reload.Allows you to do a client-side redirect that does not do a full page reload.Prevents the browser history stack from being updated.Pushes a new URL into the history stack of the browser.Can be used to do a client-side redirect to a new locationrefresh()If set to "true" the client side will do a full refresh of the pagereplaceUrl(String url) Allows you to replace the most recent entry, i.e.Set a CSS selector that allows you to choose which part of the response is used to be swapped in.reswap(HtmxReswap reswap) Set a new swap to specify how the response will be swapped.Set a CSS selector that updates the target of the content update to a different element on the pageAdds an event that will be triggered once the response is received.Adds an event that will be triggered once the response is received.triggerAfterSettle(String eventName) Adds an event that will be triggered after the settling step.triggerAfterSettle(String eventName, Object eventDetail) Adds an event that will be triggered after the settling step.triggerAfterSwap(String eventName) Adds an event that will be triggered after the swap step.triggerAfterSwap(String eventName, Object eventDetail) Adds an event that will be triggered after the swap step.Append a view name to be resolved withViewResolverimplementations and used together with the implicit model.view(org.springframework.web.servlet.ModelAndView modelAndView) Append aModelAndViewinstance to use for rendering.view(org.springframework.web.servlet.View view) Append aViewinstance to use for rendering together with the implicit model.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
and
Merges anotherHtmxResponseinto this builder.- Parameters:
otherResponse- Another HtmxResponse that will be merged into this response.- Returns:
- the builder
-
build
-
location
Allows you to do a client-side redirect that does not do a full page reload.- Parameters:
path- the path- Returns:
- the builder
- See Also:
-
location
Allows you to do a client-side redirect that does not do a full page reload.- Parameters:
location- the location- Returns:
- the builder
- See Also:
-
preventHistoryUpdate
Prevents the browser history stack from being updated.- Returns:
- the builder
- See Also:
-
- HX-Push Response Header documentation
- HX-Replace-Url Response Header
-
pushUrl
Pushes a new URL into the history stack of the browser.If you want to prevent the history stack from being updated, use
preventHistoryUpdate().- Parameters:
url- the URL to push into the history stack. The URL can be any URL in the same origin as the current URL.- Returns:
- the builder
- See Also:
-
- HX-Push Response Header documentation
- history.pushState()
-
redirect
Can be used to do a client-side redirect to a new location- Parameters:
url- the URL. Can be a relative or an absolute url- Returns:
- the builder
-
refresh
If set to "true" the client side will do a full refresh of the page- Returns:
- the builder
-
replaceUrl
Allows you to replace the most recent entry, i.e. the current URL, in the browser history stack.If you want to prevent the history stack from being updated, use
preventHistoryUpdate().- Parameters:
url- the URL to replace in the history stack. The URL can be any URL in the same origin as the current URL.- Returns:
- the builder
- See Also:
-
reswap
Set a new swap to specify how the response will be swapped.- Parameters:
reswap- the reswap options.- Returns:
- the builder
-
retarget
Set a CSS selector that updates the target of the content update to a different element on the page- Parameters:
cssSelector- the CSS selector- Returns:
- the builder
-
reselect
Set a CSS selector that allows you to choose which part of the response is used to be swapped in. Overrides an existing hx-select on the triggering element.- Parameters:
cssSelector- the CSS selector- Returns:
- the builder
-
trigger
Adds an event that will be triggered once the response is received.Multiple trigger were automatically be merged into the same header.
- Parameters:
eventName- the event name- Returns:
- the builder
- See Also:
-
trigger
Adds an event that will be triggered once the response is received.Multiple trigger were automatically be merged into the same header.
- Parameters:
eventName- the event nameeventDetail- details along with the event- Returns:
- the builder
- See Also:
-
triggerAfterSettle
Adds an event that will be triggered after the settling step.Multiple triggers were automatically be merged into the same header.
- Parameters:
eventName- the event name- Returns:
- the builder
- See Also:
-
triggerAfterSettle
Adds an event that will be triggered after the settling step.Multiple triggers were automatically be merged into the same header.
- Parameters:
eventName- the event nameeventDetail- details along with the event- Returns:
- the builder
- See Also:
-
triggerAfterSwap
Adds an event that will be triggered after the swap step.Multiple triggers were automatically be merged into the same header.
- Parameters:
eventName- the event name- Returns:
- the builder
- See Also:
-
triggerAfterSwap
Adds an event that will be triggered after the swap step.Multiple triggers were automatically be merged into the same header.
- Parameters:
eventName- the event nameeventDetail- details along with the event- Returns:
- the builder
- See Also:
-
view
Append a view name to be resolved withViewResolverimplementations and used together with the implicit model.- Parameters:
viewName- the name of the view.- Returns:
- the builder
-
view
Append aViewinstance to use for rendering together with the implicit model.- Parameters:
view- the view- Returns:
- the builder
-
view
Append aModelAndViewinstance to use for rendering.- Parameters:
modelAndView- the model and view- Returns:
- the builder
-