Class ValidateMultiple

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

    public class ValidateMultiple
    extends ValidateMultipleFields

    The <o:validateMultiple> allows the developer to validate multiple fields by either a custom validator method:

     <o:validateMultiple id="myId" components="foo bar baz" validator="#{bean.someMethod}" />
     <h:message for="myId" />
     <h:inputText id="foo" />
     <h:inputText id="bar" />
     <h:inputText id="baz" />

    whereby the method has the following signature (method name is free to your choice):

     public boolean someMethod(FacesContext context, List<UIInput> components, List<Object> values) {
         // ...

    Or, by a managed bean instance which implements the MultiFieldValidator interface:

     <o:validateMultiple id="myId" components="foo bar baz" validator="#{validateValuesBean}" />
     <h:message for="myId" />
     <h:inputText id="foo" />
     <h:inputText id="bar" />
     <h:inputText id="baz" />
     public class ValidateValuesBean implements MultiFieldValidator {
         public boolean validateValues(FacesContext context, List<UIInput> components, List<Object> values) {
             // ...

    Design notice

    Note that this validator does not throw ValidatorException, but returns a boolean! Message handling and invalidation job is up to the ValidateMultipleFields implementation who will call this method. You can customize the message by the message attribute of the tag. Refer ValidateMultipleFields documentation for general usage instructions.

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


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

      • ValidateMultiple

        public ValidateMultiple()
    • Method Detail

      • validateValues

        public boolean validateValues​(FacesContext context,
                                      List<UIInput> components,
                                      List<Object> values)
        Invoke the validator and return its outcome.
        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).
      • getValidator

        public MultiFieldValidator getValidator()
        Returns the validator instance.
        The validator instance.
      • setValidator

        public void setValidator​(MultiFieldValidator validator)
        Sets the validator instance.
        validator - The validator instance.
      • getValidateMethod

        public MethodExpression getValidateMethod()
        Returns the validator method expression.
        The validator method expression.
      • setValidateMethod

        public void setValidateMethod​(MethodExpression validateMethod)
        Sets the validator method expression.
        validateMethod - The validator method expression.