Package rife.engine
Class HxLocation
java.lang.Object
rife.engine.HxLocation
Describes an htmx client-side navigation together with its context, for
the JSON form of the
HX-Location response header.
When a location only carries a path, it will be sent as the plain
path string, exactly like Context.hxLocation(String) does. As
soon as you add any piece of context, the header switches over to htmx's
JSON object form:
c.hxLocation(new HxLocation(books).target("#main").swap("outerHTML"));
which sends:
HX-Location: {"path":"/books","target":"#main","swap":"outerHTML"}- Since:
- 1.10
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHxLocation(String path) Creates a location that navigates to a URL.HxLocation(Route route) Creates a location that navigates to a route. -
Method Summary
Modifier and TypeMethodDescriptionSets the event that will trigger the navigation request.Sets the headers that will be submitted with the navigation request.Selects only a part of the response for swapping.Sets the element that is the source of the navigation request.Sets the way in which the response will be swapped in.Sets the element that the response will be swapped into.Sets the values that will be submitted with the navigation request.
-
Constructor Details
-
HxLocation
Creates a location that navigates to a URL.- Parameters:
path- the URL to navigate to- Since:
- 1.10
- See Also:
-
HxLocation
Creates a location that navigates to a route.The URL of the route will only be resolved when the header is set, so that the navigation survives renaming and refactoring.
- Parameters:
route- the route to navigate to- Since:
- 1.10
- See Also:
-
-
Method Details
-
source
Sets the element that is the source of the navigation request.- Parameters:
cssSelector- the CSS selector of the source element- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-
event
Sets the event that will trigger the navigation request.- Parameters:
event- the name of the event- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-
target
Sets the element that the response will be swapped into.- Parameters:
cssSelector- the CSS selector of the target element- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-
swap
Sets the way in which the response will be swapped in.This takes an
hx-swapvalue, for instanceouterHTMLorbeforeend.- Parameters:
swapStyle- the swap style to use- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-
select
Selects only a part of the response for swapping.- Parameters:
cssSelector- the CSS selector to select from the response- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-
values
Sets the values that will be submitted with the navigation request.The values will be serialized to JSON with RIFE2's own
Jsonsupport, so that records, beans and maps all work.- Parameters:
values- the values to submit- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-
headers
Sets the headers that will be submitted with the navigation request.- Parameters:
headers- the headers to submit- Returns:
- this
HxLocationinstance, so that method calls can be chained - Since:
- 1.10
-