diff --git a/spring-webflow-reference/src/views.xml b/spring-webflow-reference/src/views.xml index 5be963db..472be81a 100644 --- a/spring-webflow-reference/src/views.xml +++ b/spring-webflow-reference/src/views.xml @@ -143,19 +143,22 @@ Binding to a model Use the model attribute to declare a model object the view binds to. - This attribute is typically used with views that render data controls, such as forms. + This attribute is typically used in conjunction with views that render data controls, such as forms. + It enables form data binding and validation behaviors to be driven from metadata on your model object. + + The following example declares an enterBookingDetails state manipulates the booking model: ]]> - The model may be in any accessible scope, such as flowScope or viewScope. + The model may an object in any accessible scope, such as flowScope or viewScope. Specifying a model triggers the following behavior when a view event occurs: - View-to-model binding. On view postback, form values are bound to model object properties for you. - Model validation. After binding, if the model object requires validation, that validation logic will be invoked. + View-to-model binding. On view postback, user input values are bound to model object properties for you. + Model validation. After binding, if the model object requires validation that validation logic will be invoked. For a flow event to be generated that can drive a view state transition, model binding must complete successfully. @@ -166,6 +169,7 @@ Suppressing binding Use the bind attribute to suppress model binding and validation for particular view events. + The following example suppresses binding when the cancel event occurs: @@ -174,6 +178,76 @@ ]]> + + Specifying bindings explicitly + + Use the binder element to configure the exact set of model bindings usable by the view. + This is particularly useful in a Spring MVC environment for restricting the set of "allowed fields" per view. + + + + + + + + + + + +]]> + + + If the binder element is not specified, all public properties of the model are eligible for binding by the view. + With the binder element specified, only the explicitly configured bindings are allowed. + + + Each binding may also apply a converter to format the model property value for display in a custom manner. + If no converter is specified, the default converter for the model property's type will be used. + + + + + + + + + + + + + +]]> + + + In the example above, the shortDate converter is bound to the + checkinDate and checkoutDate properties. + Custom converters may be registered with the application's ConversionService. + + + Each binding may also apply a required check that will generate a validation error + if the user provided value is null on form postback: + + + + + + + + + + + + +]]> + + + In the example above, all of the bindings are required. + If one or more blank input values are bound, validation errors will be generated and the view will re-render with those errors. + + Validating a model @@ -238,7 +312,30 @@ public class BookingValidator { + + Declarative validation + + Spring Web Flow does not yet ship integration with a declarative validation framework such as Hibernate Validator. + It is expected that integration will be provided in a future Web Flow release. + This integration will allow declarative validation constraints to be defined against model properties. + + + + Suppressing validation + + Use the validate attribute to suppress model validation for particular view events: + + + + +]]> + + + In this example, data binding will still occur on back but validation will be suppressed. + + Transition actions