From ecd213dc8feb3fb13576a353e42742b1f70bc169 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 31 Mar 2014 13:23:45 -0400 Subject: [PATCH] Update section on partial validation --- src/reference/views.xml | 49 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/reference/views.xml b/src/reference/views.xml index 3fa17482..1f53e770 100644 --- a/src/reference/views.xml +++ b/src/reference/views.xml @@ -487,39 +487,56 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio Partial Validation - JSR-303 Bean Validation supports partial validation via groups. For example: + JSR-303 Bean Validation supports partial validation through validation groups. For example: @NotNull @Size(min = 2, max = 30, groups = State1.class) private String name; - You can specify validation hints in a view state: + In a flow definition you can specify validation hints on a view state + or on a transition and those will be resolved to validation groups. + For example: + ]]> - Each hint can be an inner Class either in the model type or its parent types. - For example, given org.example.MyModel with inner type - Group1 and Group2 you can - specify the hints "group1", "group2" or both "group1,group2". - A hint can also be a fully qualified class name. - The hint "default" indicates the default validation group, i.e. - javax.validation.groups.Default. - Also, the validation-hints property can be an expression that - resolves to a String or an Object[] - containing Class based hints. + The validation-hints attribute is an expression + that in the above example resolves to a comma-delimited String consisting + of the hints "group1" and "group2". A ValidationHintResolver + is used to resolve these hints. The BeanValidationHintResolver + used by default tries to resolve these strings to Class-based bean validation + groups. To do that it looks for matching inner types in the model or its parent. - Note that a custom ValidationHintResolver can be plugged if - necessary through the validationHintResolver property of the - flow-builder-services element: + For example given org.example.MyModel with inner types + Group1 and Group2 it is + sufficient to supply the simple type names, i.e. "group1" and "group2". + You can also provide fully qualified type names. + + + A hint with the value "default" has a special meaning and is translated + to the default validation group in Bean Validation + javax.validation.groups.Default. + + + A custom ValidationHintResolver + can be configured if necessary through the validationHintResolver property + of the flow-builder-services element: <webflow:flow-registry flow-builder-services="flowBuilderServices" /> <webflow:flow-builder-services id="flowBuilderServices" validator=".." validationHintResolver=".." /> + + The above configuration example works in applications not using JSF. + For JSF applications that rely on Web Flow-based validation, + you will need to register a + custom extension of Web Flow's FlowActionListener + via faces-config.xml configured with the custom + ValidationHintResolver. +