Package io.micronaut.views.turbo
Class TurboStream.Builder
java.lang.Object
io.micronaut.views.turbo.TurboStream.Builder
- Enclosing class:
- TurboStream
Turbo Stream Builder.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NonNull TurboStream.Builder
action
(@NonNull TurboStreamAction action) @NonNull TurboStream.Builder
after()
Sets the Turbo action asTurboStreamAction.AFTER
.@NonNull TurboStream.Builder
append()
Sets the Turbo action asTurboStreamAction.APPEND
.@NonNull TurboStream.Builder
before()
Sets the Turbo action asTurboStreamAction.BEFORE
.@NonNull TurboStream
build()
@NonNull TurboStream.Builder
childrenOnly
(boolean childrenOnly) @NonNull TurboStream.Builder
morph()
Sets the Turbo action asTurboStreamAction.MORPH
.static @NonNull Optional<TurboStream.Builder>
of
(@NonNull io.micronaut.http.HttpRequest<?> request, @NonNull io.micronaut.http.HttpResponse<?> response) Creates a Turbo Stream builder if annotationTurboView
is found in the route and the request is a turbo request.@NonNull TurboStream.Builder
prepend()
Sets the Turbo action asTurboStreamAction.PREPEND
.@NonNull TurboStream.Builder
refresh()
Sets the Turbo action asTurboStreamAction.REFRESH
.@NonNull TurboStream.Builder
remove()
Sets the Turbo action asTurboStreamAction.REMOVE
.@NonNull TurboStream.Builder
replace()
Sets the Turbo action asTurboStreamAction.REPLACE
.@NonNull TurboStream.Builder
@NonNull TurboStream.Builder
targetCssQuerySelector
(@NonNull String targetCssQuerySelector) @NonNull TurboStream.Builder
targetCssQuerySelectorPattern
(@Nullable Pattern pattern) @NonNull TurboStream.Builder
targetDomId
(@NonNull String targetDomId) @NonNull TurboStream.Builder
targetDomIdPattern
(@Nullable Pattern pattern) @NonNull TurboStream.Builder
template
(@NonNull io.micronaut.core.io.Writable writable) Sets the Turbo template with aWritable
.@NonNull TurboStream.Builder
Sets the Turbo template with a String.@NonNull TurboStream.Builder
Sets the template with a View and Model.@NonNull TurboStream.Builder
templateModel
(@NonNull Object templateModel) Sets the template's model.@NonNull TurboStream.Builder
templateView
(@NonNull String templateView) Sets the template's view name.@NonNull TurboStream.Builder
update()
Sets the Turbo action asTurboStreamAction.UPDATE
.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
targetCssQuerySelectorPattern
@NonNull public @NonNull TurboStream.Builder targetCssQuerySelectorPattern(@Nullable @Nullable Pattern pattern) - Parameters:
pattern
- HTML attributes validation Pattern- Returns:
- The Builder
-
targetDomIdPattern
@NonNull public @NonNull TurboStream.Builder targetDomIdPattern(@Nullable @Nullable Pattern pattern) - Parameters:
pattern
- HTML attributes validation Pattern- Returns:
- The Builder
-
action
- Parameters:
action
- Sets the Turbo Stream Action- Returns:
- The Builder
-
targetDomId
- Parameters:
targetDomId
- Target DOM ID- Returns:
- The Builder
-
targetCssQuerySelector
@NonNull public @NonNull TurboStream.Builder targetCssQuerySelector(@NonNull @NonNull String targetCssQuerySelector) - Parameters:
targetCssQuerySelector
- Target CSS Query Selector- Returns:
- The Builder
-
requestId
- Parameters:
requestId
- request-id attribute, only relevant when action=refresh- Returns:
- The Builder
-
childrenOnly
- Parameters:
childrenOnly
- Morph only the children of the element designated by the target dom id.- Returns:
- The Builder
-
template
Sets the template with a View and Model.- Parameters:
view
- The View namemodel
- The Model- Returns:
- The Builder
-
templateView
Sets the template's view name.- Parameters:
templateView
- The View name- Returns:
- The Builder
-
templateModel
Sets the template's model.- Parameters:
templateModel
- template model.- Returns:
- The Builder
-
template
Sets the Turbo template with a String. E.g. HTML.- Parameters:
html
- The turbo template- Returns:
- The Builder
-
template
@NonNull public @NonNull TurboStream.Builder template(@NonNull @NonNull io.micronaut.core.io.Writable writable) Sets the Turbo template with aWritable
.- Parameters:
writable
- The template as aWritable
.- Returns:
- The Builder
-
append
Sets the Turbo action asTurboStreamAction.APPEND
.- Returns:
- The Builder.
-
prepend
Sets the Turbo action asTurboStreamAction.PREPEND
.- Returns:
- The Builder
-
update
Sets the Turbo action asTurboStreamAction.UPDATE
.- Returns:
- The Builder
-
remove
Sets the Turbo action asTurboStreamAction.REMOVE
.- Returns:
- The Builder.
-
after
Sets the Turbo action asTurboStreamAction.AFTER
.- Returns:
- The Builder.
-
before
Sets the Turbo action asTurboStreamAction.BEFORE
.- Returns:
- the Builder
-
replace
Sets the Turbo action asTurboStreamAction.REPLACE
.- Returns:
- the Builder
-
morph
Sets the Turbo action asTurboStreamAction.MORPH
.- Returns:
- the Builder
-
refresh
Sets the Turbo action asTurboStreamAction.REFRESH
.- Returns:
- the Builder
-
build
- Returns:
- Builds the
TurboStream
.
-
getTemplateView
- Returns:
- The TurboStream template view name.
-
getTemplateModel
- Returns:
- The TurboStream template model.
-
getTargetDomId
- Returns:
- TurboFrame Target DOM ID.
-
getTargetCssQuerySelector
- Returns:
- TurboFrame Target DOM ID.
-
of
@NonNull public static @NonNull Optional<TurboStream.Builder> of(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request, @NonNull @NonNull io.micronaut.http.HttpResponse<?> response) Creates a Turbo Stream builder if annotationTurboView
is found in the route and the request is a turbo request.- Parameters:
request
- HTTP Requestresponse
- HTTP Response- Returns:
- Creates a Turbo Stream builder if annotation
TurboView
is found in the route and the request is a turbo request.
-