Package io.github.wimdeblauwe.hsbt.mvc
Class HtmxResponse
java.lang.Object
io.github.wimdeblauwe.hsbt.mvc.HtmxResponse
Representation of HTMX partials.
- Author:
- Oliver Drotbohm, Clint Checketts
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTemplate(String template) Append the rendered template or fragment.addTrigger(String eventName) Set a HX-Trigger header.addTrigger(String eventName, String eventDetail, HxTriggerLifecycle step) Set a HX-Trigger (or HX-Trigger-After-Settle or HX-Trigger-After-Swap headers.and(HtmxResponse otherResponse) browserRedirect(String url) Can be used to do a client-side redirect to a new locationbrowserRefresh(boolean refresh) If set to "true" the client side will do a a full refresh of the pagepushHistory(String url) Pushes a new url into the history stackSet a CSS selector that updates the target of the content update to a different element on the page
-
Constructor Details
-
HtmxResponse
public HtmxResponse()
-
-
Method Details
-
addTemplate
Append the rendered template or fragment.- Parameters:
template- must not be null or empty.- Returns:
- same HtmxResponse for chaining
-
addTrigger
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
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
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:
-
- HX-Push Response Header documentation
-
browserRedirect
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
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
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
- Parameters:
otherResponse- Another HtmxResponse that will be merged into this response.- Returns:
- this for chaining
-