Options bindings¶
How to make a configuration field a picker over the elements of another
configuration list — the dynamic analogue of an EnumField's static
values. An options binding is a schema-associated artifact, a
sibling of the validation rule set; it lives in its own
optionsBindingSet { } block of the workflow type, not in the UI
configuration.
The allowed values are a semantic constraint on the field, so they
belong with the schema rather than with presentation. The block is
evaluated where the generated value models are available, so it can
reference the configuration's value models (configValueModel.…) and
the per-element model factory.
workflowType {
// … metadata, dataInterface, workflowDefinition …
configurationSchema {
// the source list the user assembles
compoundList("materials") {
string("name")
real("density")
}
// a plain compound mirroring a materials element — the picker target
compound("selectedMaterial") {
string("name")
real("density")
}
}
optionsBindingSet {
ConfigurationOptionsBindingSet(
listOf(
configValueModel.selectedMaterial.optionsBinding(
options = configValueModel.materials, // filter / sort allowed
elementModelFactory = MaterialsValueModel::fromReference,
optionLabel = { it.name }, // shown in the dropdown
allowEmptySelection = false, // true ⇒ clearable
),
),
)
}
}
Picking stores a reference to the chosen element (a whole element, by
stable id); the value is resolved on read, so source edits propagate. If
the referenced element is deleted, the reference is dangling — configuration
validation flags it as an error on the bound field, just like a missing
mandatory value. Rendering the field as a dropdown is implied by the binding
— there's nothing to add to the UiConfiguration.
Binding a field inside a list (every element)¶
A binding has two sides: the target (the field that stores the pick) and the
source (the list it picks from, passed as options). When the target lives
inside a configuration list, bind it for every element with the list's
.element() accessor — the same accessor used for per-element UI hints
(list.element().navigationUi { … }). .element() roots the target at the
list's element, so the binding's path gains a * wildcard segment; validation
applies it to each concrete element and the evaluated-options endpoint covers
them all.
The cases below differ in where the * falls. Wildcards on the target are
supported (however deep); a wildcard on the source is not (see the last case).
Always bind through
.element(), never.map { it.selectedMaterial }— a mapped list is a computed value with no field reference to bind.
Target one list deep, shared source list¶
The common case: the bound field is per-element of one list, and the list it picks from is a single, shared list elsewhere in the configuration.
configValueModel.subdomains
.element() // target: every subdomains element
.selectedMaterial
.optionsBinding(
options = configValueModel.materials, // source: one shared list
elementModelFactory = MaterialsValueModel::fromReference,
optionLabel = { it.name },
allowEmptySelection = true,
)
- target →
/subdomains/*/selectedMaterial(one*) - source →
/materials(no*— the same list for every subdomain)
Target several lists deep, shared source list¶
When the target sits inside nested lists, call .element() at each level; the
path gains one * per level. The source list is still a single shared list.
configValueModel.layerGroups
.element() // /layerGroups/*
.sublayers
.element() // /layerGroups/*/sublayers/*
.sublayerMaterial
.optionsBinding(options = configValueModel.materials, /* … */)
- target →
/layerGroups/*/sublayers/*/sublayerMaterial(two*, both on the target) - source →
/materials(no*)
There's no depth limit. Note both * are on the target — every sublayer of
every group still picks from the same /materials list.
Give nested compounds distinct names
The generated value-model class for a compound is derived from its name,
not its path, so two compounds that share a name anywhere in the schema
collide (conflicting overloads at build time). That's why the nested field
above is sublayerMaterial, not a second material. Pick a unique name per
compound.
Per-element source list — not supported¶
If each element should pick from its own sibling list (the source list is
itself per-element, so a * falls on the source path), the binding cannot be
expressed today:
// NOT SUPPORTED
configValueModel.regions
.element()
.selectedMaterial // target: /regions/*/selectedMaterial
.optionsBinding(options = /* this region's */ availableMaterials) // source: /regions/*/availableMaterials
A stored pick is a reference of the form
{ listPath, elementId }, and listPath must point at a concrete list. A
per-element source would make listPath itself contain a * (/regions/*/availableMaterials),
which can't be resolved to one list — so this shape is rejected. Keep the source
list shared (a single list the per-element targets all reference), as in the
cases above.
What gets stored¶
You don't author any of this — it's what the binding produces — but it explains the picker's behaviour. Picking writes a reference to the chosen element (by its stable id), not a copy, so renaming or reordering the source list keeps the selection intact; deleting the referenced element makes the reference dangling, which configuration validation reports as an error. On read, the reference is resolved back to the element's value. The exact JSON shapes — the stored reference, the evaluated-options response, the materialized result — are documented in the framework-developer internals doc.
Cross-references¶
- Concepts: validation rules — how the
binding relates to validation (validity reduces to referential
integrity; there's no
inOptionsrule to write). - UI configuration entries — the separate, presentation-only artifact (options bindings are not declared there).
- Reference: schema DSL — declaring the plain compound fields an options binding targets.