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
public final class DiscriminatorControl extends EditableControl<Object>
AControlfor 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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DiscriminatorControl(IValueAccessor<?> root, String path, IUnionValueDescriptor descriptor)Creates a new discriminator control.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectcoerceValue(Object value)Coerces the value to conform to the currently selected discriminator.intgetCurrentDiscriminator()Gets the currently selected discriminator.List<javax.faces.model.SelectItem>getOptions()Gets the options for the discriminator select box.voidsetCurrentDiscriminator(int discriminator)Sets the currently selected discriminator.voidupdateDiscriminator()Updates the value so that it conforms to thecurrently selected discriminator.-
Methods inherited from class de.xima.fc.gui.model.value_descriptor_form.EditableControl
getDescription, getLabel, getValue, isFcPlaceholders, isRequired, setDescription, setFcPlaceholders, setLabel, setRequired, setValue
-
Methods inherited from class de.xima.fc.gui.model.value_descriptor_form.ValueReferencingControl
readValue, writeValue
-
-
-
-
Constructor Detail
-
DiscriminatorControl
public DiscriminatorControl(IValueAccessor<?> root, String path, IUnionValueDescriptor descriptor)
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 Detail
-
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
public List<javax.faces.model.SelectItem> 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
protected Object coerceValue(Object value)
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.
-
-