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
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull TurboStream.Builderaction(@NonNull TurboStreamAction action) @NonNull TurboStream.Builderafter()Sets the Turbo action asTurboStreamAction.AFTER.@NonNull TurboStream.Builderappend()Sets the Turbo action asTurboStreamAction.APPEND.@NonNull TurboStream.Builderbefore()Sets the Turbo action asTurboStreamAction.BEFORE.@NonNull TurboStreambuild()@NonNull TurboStream.BuilderchildrenOnly(boolean childrenOnly) @NonNull TurboStream.Buildermorph()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 annotationTurboViewis found in the route and the request is a turbo request.@NonNull TurboStream.Builderprepend()Sets the Turbo action asTurboStreamAction.PREPEND.@NonNull TurboStream.Builderrefresh()Sets the Turbo action asTurboStreamAction.REFRESH.@NonNull TurboStream.Builderremove()Sets the Turbo action asTurboStreamAction.REMOVE.@NonNull TurboStream.Builderreplace()Sets the Turbo action asTurboStreamAction.REPLACE.@NonNull TurboStream.Builder@NonNull TurboStream.BuildertargetCssQuerySelector(@NonNull String targetCssQuerySelector) @NonNull TurboStream.BuildertargetCssQuerySelectorPattern(@Nullable Pattern pattern) @NonNull TurboStream.BuildertargetDomId(@NonNull String targetDomId) @NonNull TurboStream.BuildertargetDomIdPattern(@Nullable Pattern pattern) @NonNull TurboStream.Buildertemplate(@NonNull io.micronaut.core.io.Writable writable) Sets the Turbo template with aWritable.@NonNull TurboStream.BuilderSets the Turbo template with a String.@NonNull TurboStream.BuilderSets the template with a View and Model.@NonNull TurboStream.BuildertemplateModel(@NonNull Object templateModel) Sets the template's model.@NonNull TurboStream.BuildertemplateView(@NonNull String templateView) Sets the template's view name.@NonNull TurboStream.Builderupdate()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 annotationTurboViewis 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
TurboViewis found in the route and the request is a turbo request.
-