Class DiscriminatorControl
java.lang.Object
de.xima.fc.gui.model.value_descriptor_form.Control
de.xima.fc.gui.model.value_descriptor_form.ValueReferencingControl
de.xima.fc.gui.model.value_descriptor_form.EditableControl<Object>
de.xima.fc.gui.model.value_descriptor_form.DiscriminatorControl
- All Implemented Interfaces:
Serializable
A
Control for selecting the discriminator of a union value. The discriminator is used to select the value
descriptor to apply to the value. Rendered as a dropdown/select box.- Since:
- 8.5.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDiscriminatorControl(IValueAccessor<?> root, String path, IUnionValueDescriptor descriptor) Creates a new discriminator control. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectcoerceValue(Object value) Coerces the value to conform to the currently selected discriminator.intGets the currently selected discriminator.List<javax.faces.model.SelectItem> Gets the options for the discriminator select box.voidsetCurrentDiscriminator(int discriminator) Sets the currently selected discriminator.voidUpdates the value so that it conforms to thecurrently selected discriminator.Methods inherited from class EditableControl
getDescription, getLabel, getValue, isFcPlaceholders, isRequired, setDescription, setFcPlaceholders, setLabel, setRequired, setValueMethods inherited from class ValueReferencingControl
readValue, writeValue
-
Constructor Details
-
DiscriminatorControl
Creates a new discriminator control.- Parameters:
root- The root object containing the value.path- The path to the value within the root object.descriptor- The union value descriptor describing the possible union members.
-
-
Method Details
-
getCurrentDiscriminator
public int getCurrentDiscriminator()Gets the currently selected discriminator.- Returns:
- The currently selected discriminator.
-
setCurrentDiscriminator
public void setCurrentDiscriminator(int discriminator) Sets the currently selected discriminator. This WILL NOT update the value of the control to conform to the descriptor of the new discriminator. CallupdateDiscriminator()to do so.- Parameters:
discriminator- The discriminator to select.
-
getOptions
Gets the options for the discriminator select box.- Returns:
- The options for the discriminator select box.
-
updateDiscriminator
public void updateDiscriminator()Updates the value so that it conforms to thecurrently selected discriminator. If the current value does not conform to the selected discriminator, it will be replaced with a new value that does. If the discriminator has not changed, this method does nothing.Usually this method should be called during the invoke application phase of the Faces lifecycle; after the apply request values phase has completed and updated the
current discriminator. -
coerceValue
Coerces the value to conform to the currently selected discriminator.- Specified by:
coerceValuein classEditableControl<Object>- Parameters:
value- The value to coerce.- Returns:
- The coerced value, or
nullif the current discriminator is invalid.
-