Package org.ametys.odf.validator
Class RepeaterDistributionValidator
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.contenttype.validation.AbstractContentValidator
org.ametys.odf.validator.RepeaterDistributionValidator
- All Implemented Interfaces:
ContentValidator,Configurable,LogEnabled,Serviceable
public class RepeaterDistributionValidator
extends AbstractContentValidator
implements Configurable, Serviceable
This implementation of
ContentValidator validates the content by checking the distribution of weights in a repeater.
For each entry of repeater, check if the sum of the 'weight' values is equal or lower than 100.
The repater can be linked to a percentage attribute. If the percentage attribute is set to false, the validation is skipped (means that weights are not expressed as a percentage).
The repeater and weights are identified in validator's configuration by the attribute path as follows:
<repeater path="path/to/repeater" weightAttribute="weight"/>
The validator can validate multiple weight attributes in the same repeater.
To do so, multiple <attribute path="path/to/weight"/> can be defined inside the validator configuration.
The percentage attribute is identified in validator's configuration by the attribute path as follows:
<percentage path="path/to/attribute/percentage"/>-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(Configuration configuration) voidEnds the configuration of the global validator and can check if model is valid.voidservice(ServiceManager manager) Validates a content.Validates a content being editedMethods inherited from class org.ametys.cms.contenttype.validation.AbstractContentValidator
getContentType, setContentTypeMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Constructor Details
-
RepeaterDistributionValidator
public RepeaterDistributionValidator()
-
-
Method Details
-
configure
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
Description copied from interface:ContentValidatorEnds the configuration of the global validator and can check if model is valid.- Specified by:
initializein interfaceContentValidator- Overrides:
initializein classAbstractContentValidator- Throws:
ConfigurationException- if validator is not well configured
-
validate
Description copied from interface:ContentValidatorValidates a content.- Specified by:
validatein interfaceContentValidator- Parameters:
content- the content to validate- Returns:
- the validation result
-
validate
Description copied from interface:ContentValidatorValidates a content being edited- Specified by:
validatein interfaceContentValidator- Parameters:
content- the content to validatevalues- the values being setview- the view- Returns:
- the validation result
-