org.omnifaces.component.validator
Class ValidateMultiple

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.omnifaces.component.validator.ValidatorFamily
              extended by org.omnifaces.component.validator.ValidateMultipleFields
                  extended by org.omnifaces.component.validator.ValidateMultiple
All Implemented Interfaces:
java.util.EventListener, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, MultiFieldValidator

public class ValidateMultiple
extends ValidateMultipleFields

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" />
 
 @ManagedBean
 @RequestScoped
 public class ValidateValuesBean implements MultiFieldValidator {
     @Override
     public boolean validateValues(FacesContext context, List<UIInput> components, List<Object> values) {
         // ...
     }
 }
 

Since:
1.7
Author:
Juliano Marques, Bauke Scholtz
See Also:
ValidateMultipleHandler

Field Summary
static java.lang.String COMPONENT_TYPE
          The standard component type.
 
Fields inherited from class org.omnifaces.component.validator.ValidatorFamily
COMPONENT_FAMILY
 
Fields inherited from class javax.faces.component.UIComponent
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
 
Constructor Summary
ValidateMultiple()
          The default constructor sets the default message.
 
Method Summary
 javax.el.MethodExpression getValidateMethod()
          Returns the validator method expression.
 MultiFieldValidator getValidator()
          Returns the validator instance.
 void setValidateMethod(javax.el.MethodExpression validateMethod)
          Sets the validator method expression.
 void setValidator(MultiFieldValidator validator)
          Sets the validator instance.
 boolean validateValues(javax.faces.context.FacesContext context, java.util.List<javax.faces.component.UIInput> components, java.util.List<java.lang.Object> values)
          Invoke the validator and return its outcome.
 
Methods inherited from class org.omnifaces.component.validator.ValidateMultipleFields
collectComponents, collectValues, getComponents, getMessage, getShowMessageFor, isDisabled, isInvalidateAll, isValidationFailed, setComponents, setDisabled, setInvalidateAll, setMessage, setShowMessageFor, shouldInvalidateInput, showMessage, validateComponents, validateHierarchy
 
Methods inherited from class org.omnifaces.component.validator.ValidatorFamily
encodeChildren, getFamily, getRendersChildren, processDecodes, processUpdates, processValidators
 
Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent, visitTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_TYPE

public static final java.lang.String COMPONENT_TYPE
The standard component type.

See Also:
Constant Field Values
Constructor Detail

ValidateMultiple

public ValidateMultiple()
The default constructor sets the default message.

Method Detail

validateValues

public boolean validateValues(javax.faces.context.FacesContext context,
                              java.util.List<javax.faces.component.UIInput> components,
                              java.util.List<java.lang.Object> values)
Invoke the validator and return its outcome.

Parameters:
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.
Returns:
true if validation is successful, otherwise false (and thus show the message).

getValidator

public MultiFieldValidator getValidator()
Returns the validator instance.

Returns:
The validator instance.

setValidator

public void setValidator(MultiFieldValidator validator)
Sets the validator instance.

Parameters:
validator - The validator instance.

getValidateMethod

public javax.el.MethodExpression getValidateMethod()
Returns the validator method expression.

Returns:
The validator method expression.

setValidateMethod

public void setValidateMethod(javax.el.MethodExpression validateMethod)
Sets the validator method expression.

Parameters:
validateMethod - The validator method expression.