From 8fb8d3437c83059f1d452170d5825d4465ec549d Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Fri, 17 Oct 2008 14:25:04 +0000 Subject: [PATCH] documenting SWF-735 --- spring-webflow-reference/src/views.xml | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/spring-webflow-reference/src/views.xml b/spring-webflow-reference/src/views.xml index 432392f8..fdc5b3d6 100644 --- a/spring-webflow-reference/src/views.xml +++ b/spring-webflow-reference/src/views.xml @@ -326,24 +326,30 @@ public class StringToMonetaryAmount extends StringToObject { Programmatic validation There are two ways to perform model validation programatically. + Both options use a ValidationContext parameter for recording validation error messages in addition to the current Principal and user event that triggered validation. + The user event is the same value that matches against the 'on' attribute of a transition. + + + Prior to Web Flow 2.0.4, a MessageContext was required instead of a ValidationContext. + This style validator is still supported, however, the ValidationContext provides access to the MessageContext and additional information. Implementing a model validate method The first way is to define a validate method on the model object class. To do this, create a public method with the name validate${state}, where state is the id of your view-state. - The method must declare a MessageContext parameter for recording validation error messages. For example: @@ -353,19 +359,19 @@ public void validateEnterBookingDetails(MessageContext context) { The second way is to define a separate object, called a Validator, which validates your model object. To do this, create a class that defines a public method with the name validate${state}, where state is the id of your view-state. - The method must declare a parameter to accept your model object, and a MessageContext parameter for recording validation error messages. For example: