Class ValidateOrder

  • All Implemented Interfaces:
    PartialStateHolder, StateHolder, TransientStateHolder, ComponentSystemEventListener, FacesListener, SystemEventListenerHolder, EventListener, MultiFieldValidator

    public class ValidateOrder
    extends ValidateMultipleFields

    The <o:validateOrder> validates if the values of the given UIInput components as specified in the components attribute are in the order as specified by the type attribute which accepts the following values:

    • lt (default): from least to greatest, without duplicates.
    • lte: from least to greatest, allowing duplicates (equal values next to each other).
    • gt: from greatest to least, without duplicates.
    • gte: from greatest to least, allowing duplicates (equal values next to each other).

    This validator has the additional requirement that the to-be-validated values must implement Comparable. This validator throws an IllegalArgumentException when one or more of the values do not implement it. Note that when this validator is placed before all of the components, then it will only compare the raw unconverted submitted string values, not the converted object values. If you need to compare by the converted object values, then you need to place this validator after all of the components.

    The default message is

    {0}: Please fill out the values of all those fields in order

    For general usage instructions, refer ValidateMultipleFields documentation.

    Bauke Scholtz
    See Also:
    ValidateMultipleFields, ValidatorFamily, MultiFieldValidator
    • Field Detail


        public static final String COMPONENT_TYPE
        The component type, which is "org.omnifaces.component.validator.ValidateOrder".
        See Also:
        Constant Field Values
    • Constructor Detail

      • ValidateOrder

        public ValidateOrder()
    • Method Detail

      • validateValues

        public boolean validateValues​(FacesContext context,
                                      List<UIInput> components,
                                      List<Object> values)
        Validate if all values are in specified order.
        context - The faces context to work with.
        components - The input components whose values are to be validated.
        values - The values of the input components to be validated, in the same order as the components.
        true if validation is successful, otherwise false (and thus show the message).
      • getType

        public String getType()
        Returns the ordering type to be used.
        The ordering type to be used.
      • setType

        public void setType​(String type)
        Sets the ordering type to be used.
        type - The ordering type to be used.