Class ValidationHelper
java.lang.Object
org.springframework.webflow.validation.ValidationHelper
A helper class the encapsulates conventions to invoke validation logic.
- Author:
- Scott Andrews, Canny Duck, Jeremy Grelle
-
Constructor Summary
ConstructorDescriptionValidationHelper
(Object model, RequestContext requestContext, String eventId, String modelName, ExpressionParser expressionParser, org.springframework.validation.MessageCodesResolver messageCodesResolver, MappingResults mappingResults) An alternative constructor that creates an instance ofBeanValidationHintResolver
.ValidationHelper
(Object model, RequestContext requestContext, String eventId, String modelName, ExpressionParser expressionParser, org.springframework.validation.MessageCodesResolver messageCodesResolver, MappingResults mappingResults, ValidationHintResolver hintResolver) Create a throwaway validation helper object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
setValidationHints
(Object[] validationHints) Provide validation hints (e.g.void
setValidator
(org.springframework.validation.Validator validator) Configure aValidator
to apply to the model.void
validate()
Invoke the validators available by convention.
-
Constructor Details
-
ValidationHelper
public ValidationHelper(Object model, RequestContext requestContext, String eventId, String modelName, ExpressionParser expressionParser, org.springframework.validation.MessageCodesResolver messageCodesResolver, MappingResults mappingResults, ValidationHintResolver hintResolver) Create a throwaway validation helper object. Validation is invoked by thevalidate()
method.Validation methods invoked include a validation method on the model object or a validator bean. The method name on either object is in the form of validate[viewStateId]. A ValidationContext is passed in the method signature along with the model object for validator beans. A MessageContext can be substituted for the ValidationContext.
For example:
model.validateEnterBookingDetails(VaticationContext)
orcontext.getBean("modelValidator").validateEnterBookingDetails(model, VaticationContext)
- Parameters:
model
- the object to validaterequestContext
- the context for the requesteventId
- the event triggering validationmodelName
- the name of the model objectexpressionParser
- the expression parsermappingResults
- object mapping results
-
ValidationHelper
public ValidationHelper(Object model, RequestContext requestContext, String eventId, String modelName, ExpressionParser expressionParser, org.springframework.validation.MessageCodesResolver messageCodesResolver, MappingResults mappingResults) An alternative constructor that creates an instance ofBeanValidationHintResolver
.
-
-
Method Details
-
setValidator
public void setValidator(org.springframework.validation.Validator validator) Configure aValidator
to apply to the model. -
setValidationHints
Provide validation hints (e.g. JSR-303 validation groups). Note that the constructor automatically detects validation hints specified on a view state or a transition. Therefore use of this method should not be needed. -
validate
public void validate()Invoke the validators available by convention.
-