Package org.zkoss.bind.impl
Class ValidationContextImpl
- java.lang.Object
-
- org.zkoss.bind.impl.ValidationContextImpl
-
- All Implemented Interfaces:
ValidationContext
public class ValidationContextImpl extends java.lang.Object implements ValidationContext
the default implementation of validation context- Since:
- 6.0.0
- Author:
- dennis
-
-
Constructor Summary
Constructors Constructor Description ValidationContextImpl(java.lang.String command, Property property, java.util.Map<java.lang.String,Property[]> properties, BindContext ctx, boolean valid)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BindContextgetBindContext()java.lang.StringgetCommand()get the command that trigger the validationjava.util.Map<java.lang.String,Property[]>getProperties()get dependent properties that need to be validated.java.util.Map<java.lang.String,Property>getProperties(java.lang.Object base)get dependent properties by a base object.Property[]getProperties(java.lang.String name)get dependent properties by the property name.PropertygetProperty()get the main property that need to be validated.java.lang.ObjectgetValidatorArg(java.lang.String key)Returns validator arg value of the given key This is a shortcut ofgetBindContext().getValidatorArg()booleanisLocalValid()Checks status of local validation context valid or not, it only relates to one validator.booleanisValid()Checks status of validation context valid or not, it is a global status of same command, any validator of this validation phase callValidationContext.setInvalid()will set this false.voidsetInvalid()set invalid
-
-
-
Constructor Detail
-
ValidationContextImpl
public ValidationContextImpl(java.lang.String command, Property property, java.util.Map<java.lang.String,Property[]> properties, BindContext ctx, boolean valid)
-
-
Method Detail
-
getBindContext
public BindContext getBindContext()
- Specified by:
getBindContextin interfaceValidationContext- Returns:
- current bind context
-
getCommand
public java.lang.String getCommand()
Description copied from interface:ValidationContextget the command that trigger the validation- Specified by:
getCommandin interfaceValidationContext- Returns:
- the command, null if a prompt-save-binding
-
getProperties
public java.util.Map<java.lang.String,Property[]> getProperties()
Description copied from interface:ValidationContextget dependent properties that need to be validated. you usually use this method to get value of other properties to do complex validation or a form validation Notice that if the property is under a collection, you would see "$each", which represents "each"- Specified by:
getPropertiesin interfaceValidationContext- Returns:
- the properties map.
-
getProperties
public Property[] getProperties(java.lang.String name)
Description copied from interface:ValidationContextget dependent properties by the property name. you usually use this method to get a value of other properties to do complex validation or a form validation Notice that if the property is under a collection, you would see "$each", which represents "each"- Specified by:
getPropertiesin interfaceValidationContext- Parameters:
name- the property name- Returns:
- the properties array
-
getProperties
public java.util.Map<java.lang.String,Property> getProperties(java.lang.Object base)
Description copied from interface:ValidationContextget dependent properties by a base object. this method returns a Map (key is the property name) of properties that have same base object. It is useful in the form validation case to get all dependent property that related to a form. For example in a validator of a form,
Notice that if the property is under a collection, you would see "$each", which represents "each"Map<String,Property> beanProps = ctx.getProperties(ctx.getProperty().getBase()); Map<String,Property> formProps = ctx.getProperties(ctx.getProperty().getValue());- Specified by:
getPropertiesin interfaceValidationContext- Parameters:
base- the base object of properties- Returns:
- a Map of properties that has same base object.
-
getValidatorArg
public java.lang.Object getValidatorArg(java.lang.String key)
Description copied from interface:ValidationContextReturns validator arg value of the given key This is a shortcut ofgetBindContext().getValidatorArg()- Specified by:
getValidatorArgin interfaceValidationContext- Parameters:
key- the key to the value.- Returns:
- value of validator arg of the given key
-
getProperty
public Property getProperty()
Description copied from interface:ValidationContextget the main property that need to be validated. Notice that if the property is under a collection, you would see "$each", which represents "each"- Specified by:
getPropertyin interfaceValidationContext- Returns:
- the main property.
-
isValid
public boolean isValid()
Description copied from interface:ValidationContextChecks status of validation context valid or not, it is a global status of same command, any validator of this validation phase callValidationContext.setInvalid()will set this false.- Specified by:
isValidin interfaceValidationContext- Returns:
- true of result is valid, false if any
ValidatorcalledValidationContext.setInvalid(). Note, default is true.
-
isLocalValid
public boolean isLocalValid()
Description copied from interface:ValidationContextChecks status of local validation context valid or not, it only relates to one validator.- Specified by:
isLocalValidin interfaceValidationContext- Returns:
- true of result is valid, false if this
ValidatorcalledValidationContext.setInvalid(), default is true.
-
setInvalid
public void setInvalid()
Description copied from interface:ValidationContextset invalid- Specified by:
setInvalidin interfaceValidationContext
-
-