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" />
@ManagedBean @RequestScoped public class ValidateValuesBean implements MultiFieldValidator { @Override public boolean validateValues(FacesContext context, List<UIInput> components, List<Object> values) { // ... } }
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.
ValidateMultipleHandler
,
ValidateMultipleFields
,
ValidatorFamily
,
MultiFieldValidator
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_TYPE
The standard component type.
|
COMPONENT_FAMILY
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
Constructor and Description |
---|
ValidateMultiple() |
Modifier and Type | Method and Description |
---|---|
MethodExpression |
getValidateMethod()
Returns the validator method expression.
|
MultiFieldValidator |
getValidator()
Returns the validator instance.
|
void |
setValidateMethod(MethodExpression validateMethod)
Sets the validator method expression.
|
void |
setValidator(MultiFieldValidator validator)
Sets the validator instance.
|
boolean |
validateValues(FacesContext context,
List<UIInput> components,
List<Object> values)
Invoke the validator and return its outcome.
|
collectComponents, collectValues, getComponents, getMessage, getShowMessageFor, isDisabled, isInvalidateAll, isValidationFailed, setComponents, setDisabled, setInvalidateAll, setMessage, setShowMessageFor, shouldInvalidateInput, showMessage, validateComponents, validateHierarchy
encodeChildren, getFamily, getRendersChildren, processDecodes, processUpdates, processValidators
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
public static final String COMPONENT_TYPE
public boolean validateValues(FacesContext context, List<UIInput> components, List<Object> values)
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.true
if validation is successful, otherwise false
(and thus show the message).public MultiFieldValidator getValidator()
public void setValidator(MultiFieldValidator validator)
validator
- The validator instance.public MethodExpression getValidateMethod()
public void setValidateMethod(MethodExpression validateMethod)
validateMethod
- The validator method expression.Copyright © 2012–2018 OmniFaces. All rights reserved.