Class
caplin.presenter.node

SelectionField

A PresentationNode containing all of the attributes necessary to model a selection field on screen.

Selection fields can be rendered using a number of different controls:

  • radio buttons
  • select box
  • combo box
  • toggle switch (only when there are exactly two options)

By default, selection fields automatically add a validator for the case where the currently entered #value isn't one of the available #options — this can occur when you render the selection field using a combo box, or the underlying options change so the currently selected value is no longer an available option. You can disable these validation errors by invoking #allowInvalidSelections with true.

Constructor Summary

Attributes Name and Description
caplin.presenter.node.SelectionField(Object vOptions, Object vValue)

Constructs a new instance of SelectionField.

Field Summary

Attributes Name and Description
controlName

The logical control-name the selection field is being bound to — this value will appear within the name attribute if being bound to a native HTML control.

enabled

A boolean property representing whether the selection field is enabled or not.

failureMessage

A textual description of the currently failing validation message when #hasError is true.

hasError

A boolean property that is true if #value has any validation errors, and false otherwise.

label

The textual label associated with the selection field.

options

The current list of options the user can select from.

value

The currently selected option, or potentially any string the user has entered if being displayed with a combo-box.

visible

A boolean property representing whether the selection field is visible or not.

Method Summary

Attributes Name and Description
void allowInvalidSelections(boolean bAllowInvalidSelections)

Whether the selection field displays a validation error if the selected #value is not a member of the #options array.

void automaticallyUpdateValueWhenOptionsChange(boolean bAutomaticallyUpdate)

Whether the selection field automatically picks a new #value when the underlying #options change.

Methods inherited from class caplin.presenter.node.PresentationNode:
getPath, nodes, properties, removeAllListeners, removeChildListeners

Constructor Detail

caplin.presenter.node.SelectionField(Object vOptions, Object vValue)

Constructs a new instance of SelectionField.

Parameters
Object vOptions The list of available options, either using an array, a map or an caplin.presenter.node.OptionsNodeList.
Object vValue (optional) The initial value of the field, either using a primitive type or an caplin.presenter.property.EditableProperty.

Field Detail

caplin.presenter.property.WritableProperty controlName

The logical control-name the selection field is being bound to — this value will appear within the name attribute if being bound to a native HTML control.

caplin.presenter.property.WritableProperty enabled

A boolean property representing whether the selection field is enabled or not.

caplin.presenter.property.WritableProperty failureMessage

A textual description of the currently failing validation message when #hasError is true.

caplin.presenter.property.WritableProperty hasError

A boolean property that is true if #value has any validation errors, and false otherwise.

caplin.presenter.property.WritableProperty label

The textual label associated with the selection field.

caplin.presenter.node.OptionsNodeList options

The current list of options the user can select from.

caplin.presenter.property.WritableProperty value

The currently selected option, or potentially any string the user has entered if being displayed with a combo-box.

caplin.presenter.property.WritableProperty visible

A boolean property representing whether the selection field is visible or not.

Method Detail

void allowInvalidSelections(boolean bAllowInvalidSelections)

Whether the selection field displays a validation error if the selected #value is not a member of the #options array.

Invalid selections cause validation errors by default, but this may not always be the desired behaviour, for example if the SelectionField is being displayed using a combo-box, where the #options are acting merely as suggestions, rather than as the absolute set of options.

Parameters
boolean bAllowInvalidSelections Invalid selections are allowed when set to true.

void automaticallyUpdateValueWhenOptionsChange(boolean bAutomaticallyUpdate)

Whether the selection field automatically picks a new #value when the underlying #options change.

If the underlying #options change, so that the new list of #options no longer includes the currently selected #value, a validation error will be displayed by default. In some circumstances, it may make sense to have the selection field automatically pick a new value automatically.

Parameters
boolean bAutomaticallyUpdate
See
#allowInvalidSelections