Class FormlyBuilder<T extends FormlyBuilder<T>>
java.lang.Object
io.openems.edge.core.appmanager.formly.builder.FormlyBuilder<T>
- Direct Known Subclasses:
CheckboxBuilder
,DateTimeBuilder
,FieldGroupBuilder
,InputBuilder
,RangeBuilder
,ReorderArrayBuilder
,RepeatBuilder
,SelectBuilder
,SelectGroupBuilder
,TextBuilder
public abstract class FormlyBuilder<T extends FormlyBuilder<T>>
extends Object
implements OnlyIf<T>, Self<T>
A Builder for a Formly field.
{
"key": "key",
"type": "input",
"templateOptions": {
"label": "label",
"required": true
},
"expressionProperties": {
"templateOptions.required": "model.PROPERTY"
},
"hideExpression": "!model.PROPERTY",
"defaultValue": "defaultValue",
"wrappers": []Wrappers
}
-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.google.gson.JsonObject
protected final com.google.gson.JsonObject
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal T
addWrapper
(Wrappers wrapper) Adds a wrapper to the current input.com.google.gson.JsonObject
build()
final T
disabled
(boolean disabled) Sets if input is disabled by default.final com.google.gson.JsonElement
protected final com.google.gson.JsonObject
protected abstract String
getType()
protected final com.google.gson.JsonObject
final T
hide
(boolean hide) Sets if input is hidden by default.hideKey()
Hides the current key of the input.final T
isRequired
(boolean isRequired) Sets if the input is required.final T
onlyShowIf
(BooleanExpression expression) Only shows the current input if the giveninvalid reference
ExpressionBuilder
final T
readonly
(boolean readonly) Sets if input is readonly.self()
Gets itself.setCustomValidation
(String name, BooleanExpression validationExpression, StringExpression messageExpression, Nameable propertyToShowError) Sets a custom validation of the input.setCustomValidation
(String name, BooleanExpression validationExpression, String errorMessage) setCustomValidation
(String name, BooleanExpression validationExpression, String errorMessage, Nameable propertyToShowError) final T
setDefaultValue
(com.google.gson.JsonElement defaultValue) final T
setDefaultValue
(Boolean defaultValue) final T
setDefaultValue
(Number defaultValue) final T
setDefaultValue
(String defaultValue) final T
setDefaultValueCases
(DefaultValueOptions... defaultValueOptions) final T
setDefaultValueWithBooleanSupplier
(Supplier<Boolean> supplieDefaultValue) final T
setDefaultValueWithStringSupplier
(Supplier<String> supplieDefaultValue) final T
setDescription
(String description) final T
final T
final T
setLabelExpression
(StringExpression expression)
-
Field Details
-
jsonObject
protected final com.google.gson.JsonObject jsonObject -
templateOptions
protected final com.google.gson.JsonObject templateOptions
-
-
Constructor Details
-
FormlyBuilder
-
-
Method Details
-
setKey
-
setDefaultValue
-
setDefaultValue
-
setDefaultValue
-
setDefaultValue
-
setDefaultValueWithStringSupplier
-
setDefaultValueWithBooleanSupplier
-
getDefaultValue
public final com.google.gson.JsonElement getDefaultValue() -
isRequired
Sets if the input is required. Default: 'false'- Parameters:
isRequired
- if the input is required- Returns:
- this
-
setLabel
-
setDescription
-
onlyShowIf
Only shows the current input if the giveninvalid reference
ExpressionBuilder
- Parameters:
expression
- theBooleanExpression
to set- Returns:
- this
-
hide
Sets if input is hidden by default.- Parameters:
hide
- true if the input should be hidden- Returns:
- this
-
disabled
Sets if input is disabled by default.- Parameters:
disabled
- true if the input should be disabled- Returns:
- this
-
readonly
Sets if input is readonly.- Parameters:
readonly
- true if the input should be readonly- Returns:
- this
-
setLabelExpression
-
setDefaultValueCases
-
hideKey
Hides the current key of the input. Results are all child inputs are not in the model as a JsonObject value of this key instead the are on the same level saved as this field.- Returns:
- this
-
addWrapper
Adds a wrapper to the current input.- Parameters:
wrapper
- theWrappers
to add- Returns:
- this
-
setCustomValidation
public T setCustomValidation(String name, BooleanExpression validationExpression, String errorMessage, Nameable propertyToShowError) -
setCustomValidation
public T setCustomValidation(String name, BooleanExpression validationExpression, StringExpression messageExpression, Nameable propertyToShowError) Sets a custom validation of the input.This sets a formly validation like explained in the formly documentation with the exception, that the validation is not directly passed as a function instead it needs to be a string which is converted into a validation function from the ui. If you want detailed information about how the string gets converted to a function in the ui have a look at the post process function here.
Inside the string expression you have access to:
- model: the current values
- formState: the state of the form
- field: the current field
- control: the form control
- initialModel: the initial model (only set when modifying an existing instance)
- Parameters:
name
- the name of the validationvalidationExpression
- the expression of the validationmessageExpression
- the expression of the error messagepropertyToShowError
- the path property to show the error message- Returns:
- this
-
setCustomValidation
public T setCustomValidation(String name, BooleanExpression validationExpression, String errorMessage) -
build
public com.google.gson.JsonObject build() -
getType
-
getExpressionProperties
protected final com.google.gson.JsonObject getExpressionProperties() -
getValidators
protected final com.google.gson.JsonObject getValidators() -
self
Description copied from interface:Self
Gets itself.- Specified by:
self
in interfaceSelf<T extends FormlyBuilder<T>>
- Returns:
- this
-